問題タブ [posixct]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
r - ベクトルから最初のデートを取得するにはどうすればよいですか?
POSIXctオブジェクトのベクトルがあります。リストの最初と最後の日付/時刻の値を決定したいと思います。
r - 日付データをプロットする ggplot2 からのエラー -- TRUE/FALSE が必要な場所に値がありません
外部ソースから取得しているいくつかの成績をプロットしようとしています。日付形式は次のようになります。
だから私はそれを解析してstrptime(date, "%FT%X")
取得しPOSIXlt
ます。最終的には、次のような完全なデータ フレームになります。
次の構造を使用します。
このデータをプロットしようとすると:
ここで何が間違っているのかわかりません。これを行うことで、日付処理に絞り込みました。
...しかし、どうすれば日付を正しく処理できますか?
r - POSIX オブジェクトを処理し、n 番目の N 曜日を返す R パッケージはありますか?
日付の範囲を指定すると、特定の曜日の名前と、特定の月のその日の発生 (たとえば、毎月の第 2 金曜日) が対応する日付を返す関数を作成しました。ただし、それほど高速ではなく、その堅牢性を 100% 確信しているわけではありません。POSIXオブジェクトに対してこれらの種類の操作を実行できるRのパッケージまたは関数のセットはありますか? 前もって感謝します!
r - How R formats POSIXct with fractional seconds
I believe that R incorrectly formats POSIXct types with fractional seconds. I submitted this via R-bugs as an enhancement request and got brushed off with "we think the current behavior is correct -- bug deleted." While I am very appreciative of the work they have done and continue to do, I wanted to get other peoples' take on this particular issue, and perhaps advice on how to make the point more effectively.
Here is an example:
That is, tt is created as a POSIXct time with fractional part .3 seconds. When it is printed with one decimal digit, the value shown is .2. I work a lot with timestamps of millisecond precision and it causes me a lot of headaches that times are often printed one notch lower than the actual value.
Here is what is happening: POSIXct is a floating-point number of seconds since the epoch. All integer values are handled precisely, but in base-2 floating point, the closest value to .3 is very slightly smaller than .3. The stated behavior of strftime()
for format %OSn
is to round down to the requested number of decimal digits, so the displayed result is .2. For other fractional parts the floating point value is slightly above the value entered and the display gives the expected result:
The developers' argument is that for time types we should always round down to the requested precision. For example, if the time is 11:59:59.8 then printing it with format %H:%M
should give "11:59" not "12:00", and %H:%M:%S
should give "11:59:59" not "12:00:00". I agree with this for integer numbers of seconds and for format flag %S
, but I think the behavior should be different for format flags that are designed for fractional parts of seconds. I would like to see %OSn
use round-to-nearest behavior even for n = 0
while %S
uses round-down, so that printing 11:59:59.8 with format %H:%M:%OS0
would give "12:00:00". This would not affect anything for integer numbers of seconds because those are always represented precisely, but it would more naturally handle round-off errors for fractional seconds.
This is how printing of fractional parts is handled in, for example C, because integer casting rounds down:
I did a quick survey of how fractional seconds are handled in other languages and environments, and there really doens't seem to be a consensus. Most constructs are designed for integer numbers of seconds and the fractional parts are an afterthought. It seems to me that in this case the R developers made a choice that is not completely unreasonable but is in fact not the best one, and is not consistent with the conventions elsewhere for displaying floating-point numbers.
What are peoples' thoughts? Is the R behavior correct? Is it the way you yourself would design it?
r - Rで日付をプロットする際の問題
私はRに比較的慣れておらず、グループ化されたデータを日付に対してプロットするのに問題があります。4年間にわたって月ごとにグループ化されたカウントデータがあります。2008 年 5 月を 2009 年 5 月とグループ化するのではなく、各年の各月を標準誤差でポイントします。これまでのコードは次のとおりですが、ポイントのない空白のグラフが表示されます。axis.POSIXct 行を取り除くことができ、ポイントとエラー バーを含むグラフが得られます。問題は、プロットと軸のスケーリングまたはデータ形式にあるようです。誰でもここで私を助けることができますか?
r - R as.POSIXct(Sys.Date()) は 1 日早い日付を返します
何が欠けていますか?
ご協力いただきありがとうございます
r - エポック日付は正しいのに、POSIXct オブジェクトのオフセットとして機能しないのはなぜですか?
POSIXct オブジェクトのベクトルがあります。
UNIX エポックepoch
の POSIXct オブジェクトを定義する変数を作成します。
次に、dates
ベクトルをループして値を出力します。オフセットは次のepoch
とおりです。
dates
の値とそれらの同じ値の表現の間には、 に対して 5 時間のオフセット エラーがあるようepoch
です。
ESTとUTCは+5時間の差がありますがepoch
、tz
オプションでESTのタイムゾーンを指定しました。を印刷するepoch
と、時刻情報はなく、日付のみのようです。
または にバグがありますstrptime
かas.POSIXct
、それともオフセットを計算しているか、epoch
間違って生成していますか?
r - as.Date()を使用してBST / GMTタグでPOSIXct日付を変換するR
Zoo オブジェクトのインデックスで as.Date を使用する必要があります。日付の一部は BST にあるため、変換すると、これらのエントリ (のみ) で 1 日が失われます。1 時間の違いや、日付の時刻の部分についてはまったく気にしません。表示される日付が同じままであることを確認したいだけです。これはそれほど難しいことではないと思いますが、管理できません。誰か助けてくれませんか?
最小限の再現可能な例 (zoo
パッケージを必要としない):
r - クラスをRに保ちながら、POSIXlt時間から時間を加算/減算する方法は?
私はいくつかのPOSIXlt
DateTime オブジェクトを操作しています。たとえば、1 時間を追加したいとします。
事は私がオブジェクトになりたいということnew.lt
ですPOSIXlt
。as.POSIXlt
に戻すために使用できることはわかっていますPOSIXlt
が、これを達成するためのよりエレガントで効率的な方法はありますか?