Document as.IDate() behaviour with fractional dates

オープン 初心者向け
#7,952 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
78/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
r
領域
documentation

調査の方向性

この動作は、Date 型の入力に対する as.IDate() が as.integer() を経由するため、エポックに向かって丸められることに起因します。レポートの例は、先に切り捨てた場合との違いを示しています。as.IDate のドキュメント(Rd ファイルまたは roxygen ブロック)を見つけ、小数を含む Date の値はゼロに向かって切り捨てられるという短い注記を、issue の例とともに追加してください。ヘルプページに丸めの動作が記載され、例が引き続き実行できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

beginner-task

as.IDate() calls as.integer() on Date input which means fractional dates are rounded towards the unix epoch. This leads to the following behaviour.

(origin <- .Date(0))
#> [1] "1970-01-01"
(dates <- c(origin - 0.2, origin + 0.2))
#> [1] "1969-12-31" "1970-01-01"
data.table::as.IDate(dates)
#> [1] "1970-01-01" "1970-01-01"

# I believe this is being done internally with the 'Date' method
as.integer(dates)
#> [1] 0 0

# Alternative is to floor first
as.integer(floor(unclass(dates)))
#> [1] -1  0

To me flooring is the more 'expected' result so (assuming it is not something you wish to change) is it worth pointing this behaviour out explicitly in the documentation. Apologies if I've missed this but couldn't see it mentioned.

主要言語
R
スター
3.9k
フォーク
1.1k
平均マージ
1日 8時間
マージ済み PR(30日)
14

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Rdatatable/data.table のほかの issue

Rdatatable/data.table の issue をすべて見る

似ている issue

R の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。