Skip to content

Commit 7bc8bc1

Browse files
mcolMichaelChirico
andauthored
fwrite: Improve validation of the na argument (#7867)
* fwrite: Improve validation of the na argument. * Simplify conversion to character. * Add NEWS. * preferred min-diff fix * NEWS entries are 'Notes', not bug fixes --------- Co-authored-by: Michael Chirico <chiricom@google.com>
1 parent 6793af2 commit 7bc8bc1

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

NEWS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@
8080

8181
18. `example(local=TRUE)` where the example uses `[.data.table` works again (e.g. `example(':=', package='data.table', local=TRUE, echo=FALSE)`), [#7855](https://github.com/Rdatatable/data.table/issues/7855) re-fixing [#2972](https://github.com/Rdatatable/data.table/issues/2972). Thanks @michaelChirico for the fix.
8282

83-
19. `fread()` returns a clearer error message when `dec = NA` is used, [#7737](https://github.com/Rdatatable/data.table/issues/7737). Thanks @mcol for the report and the fix.
84-
8583
### Notes
8684

8785
1. {data.table} now depends on R 3.5.0 (2018).
@@ -100,6 +98,10 @@
10098

10199
8. Clarified `fread()` documentation and vignette regarding the interaction between `keepLeadingZeros = TRUE` and automatic header detection, [#5405](https://github.com/Rdatatable/data.table/issues/5405). Thanks @clemenskuehn for the report and @venom1204 for updating the documentation.
102100

101+
9. `fread()` returns a clearer error message when `dec = NA` is used, [#7737](https://github.com/Rdatatable/data.table/issues/7737). Thanks @mcol for the report and the fix.
102+
103+
10. `fwrite()` returns a clearer error message when `na = data.frame()` is used, [#7866](https://github.com/Rdatatable/data.table/issues/7866). Thanks @mcol for the report and the fix.
104+
103105
## data.table [v1.18.4](https://github.com/Rdatatable/data.table/milestone/45) (6 May 2026)
104106

105107
### BUG FIXES

R/fwrite.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fwrite = function(x, file="", append=FALSE, quote="auto",
1515
verbose=getOption("datatable.verbose", FALSE),
1616
encoding = "",
1717
forceDecimal = FALSE) {
18-
na = as.character(na[1L]) # fix for #1725
18+
na = as.character(na) # fix for #1725
1919
if (length(encoding) != 1L || !encoding %chin% c("", "UTF-8", "native")) {
2020
stopf("Argument 'encoding' must be '', 'UTF-8' or 'native'.")
2121
}

inst/tests/tests.Rraw

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10018,6 +10018,7 @@ test(1676.1, fwrite(dt, f, na=NULL), error=base_messages$stopifnot("length(na) =
1001810018
fwrite(dt, f, na=NA)
1001910019
test(1676.2, fread(f), data.table(x=1:2, y=c(NA, "a")))
1002010020
unlink(f)
10021+
test(1676.3, fwrite(dt, na=data.frame()), error=base_messages$stopifnot("length(na) == 1L"))
1002110022

1002210023
# duplicate names in foverlaps #1730
1002310024
a = data.table(start = 1:5, end = 2:6, c2 = rnorm(10), c2 = rnorm(10), key=c("start","end"))

0 commit comments

Comments
 (0)