Document as.IDate() behaviour with fractional dates
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 78/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- r
- Domain
- documentation
Research direction
The behaviour comes from as.IDate() for Date input, which goes through as.integer() and so rounds toward the epoch; the report's examples show the difference from flooring first. Find the as.IDate documentation (its Rd file or roxygen block) and add a short note that fractional Date values are truncated toward zero, with the example from the issue. Done when the help page states the rounding and the examples still run.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 14
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
beginner-task
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7948 · 2 comments ·
Maintainers usually reply within 1 day
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one)Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
Maintainers usually reply within 1 day
-
test() doesn't distinguish plain NA_real_, NaNPossibly taken @MichaelChirico claimed this 95 days ago. Openconsistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
Maintainers usually reply within 1 day
-
HAVE_LONG_DOUBLE is conditioned on but never setPossibly taken @venom1204 claimed this 539 days ago. Openinternals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
Maintainers usually reply within 1 day
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
Maintainers usually reply within 1 day
All issues in Rdatatable/data.table
Similar issues
-
priority: could techdebt
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/ML-For-Beginners#1061 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rapporteket/rapbase#535 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
PecanProject/pecan#4218 · 1 comment ·
Maintainers usually reply within 3 days