`fwrite(dateTimeAs = "write.csv")` is not aligned with `write.csv()`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start by reproducing the minimal example with fwrite(dateTimeAs = "write.csv"), write.csv(), and options("digits.secs"). Then locate the existing fwrite dateTimeAs coverage and determine how timestamp precision is selected; done means fwrite preserves the millisecond portion by default in the same way as write.csv, with regression coverage.
Written by the indexing model from the issue text.
Description
I just tried to replace some write.csv calls with fwrite using its dateTimeAs = "write.csv" option and noticed that by default (without setting digits.secs) fwrite removes the millisecond portion from the timestamps, which is not (or no longer) the case when using write.csv.
The background was discussed here. However, it seems only a corresponding test was adapted and fwrite was not aligned with write.csv.
Is this intentional? I think it's confusing.
Minimal reproducible example
library(data.table)
options("digits.secs")
# options(digits.secs = 3L)
DT <- data.table(TS = as.POSIXct("2026-02-26 13:21:49.123"))
write.csv(DT, file = "write.csv", quote = FALSE, row.names = FALSE)
readLines("write.csv")
# [1] "TS" "2026-02-26 13:21:49.123"
fwrite(DT, file = "fwrite.csv", dateTimeAs = "write.csv")
readLines("fwrite.csv")
# [1] "TS" "2026-02-26 13:21:49"
sessionInfo()
R version 4.5.2 (2025-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
Matrix products: default
LAPACK version 3.12.1
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: Europe/Berlin
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.18.2.1
loaded via a namespace (and not attached):
[1] compiler_4.5.2 cli_3.6.5 tools_4.5.2 rstudioapi_0.18.0 pkgload_1.5.0
[6] rlang_1.1.7
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor 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
-
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 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·