diff --git a/NEWS.md b/NEWS.md index 5f2dd62cd..b4d9323ce 100644 --- a/NEWS.md +++ b/NEWS.md @@ -143,6 +143,8 @@ rowwiseDT( 9. `key<-`, marked as deprecated since 2012 and unusable since v1.15.0, has been fully removed. +10. Deprecation of `logicalAsInt` argument to `fwrite()` has been upgraded from a warning (since v1.15.0) to an error. It will be removed in the next release. + # data.table [v1.16.2](https://github.com/Rdatatable/data.table/milestone/35) (9 October 2024) ## BUG FIXES diff --git a/R/fwrite.R b/R/fwrite.R index 6f40067c2..210f1d0bf 100644 --- a/R/fwrite.R +++ b/R/fwrite.R @@ -3,8 +3,8 @@ fwrite = function(x, file="", append=FALSE, quote="auto", sep2=c("","|",""), eol=if (.Platform$OS.type=="windows") "\r\n" else "\n", na="", dec=".", row.names=FALSE, col.names=TRUE, qmethod=c("double","escape"), - logical01=getOption("datatable.logical01", FALSE), - logicalAsInt=logical01, + logical01=getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS + logicalAsInt=NULL, scipen=getOption('scipen', 0L), dateTimeAs = c("ISO","squash","epoch","write.csv"), buffMB=8, nThread=getDTthreads(verbose), @@ -24,12 +24,8 @@ fwrite = function(x, file="", append=FALSE, quote="auto", else if (length(dateTimeAs)>1L) stopf("dateTimeAs must be a single string") dateTimeAs = chmatch(dateTimeAs, c("ISO","squash","epoch","write.csv"))-1L if (is.na(dateTimeAs)) stopf("dateTimeAs must be 'ISO','squash','epoch' or 'write.csv'") - if (!missing(logical01) && !missing(logicalAsInt)) - stopf("logicalAsInt has been renamed logical01. Use logical01 only, not both.") - if (!missing(logicalAsInt)) { - warningf("logicalAsInt has been renamed logical01 for consistency with fread. It works fine for now but please change to logical01 at your convenience so we can remove logicalAsInt in future.") - logical01 = logicalAsInt - logicalAsInt=NULL + if (!is.null(logicalAsInt)) { + stopf("logicalAsInt has been renamed logical01 for consistency with fread.") } scipen = if (is.numeric(scipen)) as.integer(scipen) else 0L buffMB = as.integer(buffMB) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 39bce9730..c088474db 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -10933,10 +10933,7 @@ test(1736.03, fwrite(DT, sep2=c("",",","")), error="sep.*,.*sep2.*,.*must all be test(1736.04, fwrite(DT, sep2=c("","||","")), error="nchar.*sep2.*2") test(1736.05, capture.output(fwrite(DT, sep='|', sep2=c("c(",",",")"), logical01=FALSE)), c("A|B|C", "1|c(1,2,3,4,5,6,7,8,9,10)|c(s,t,u,v,w)", "2|c(15,16,17,18)|c(1.2,2.3,3.4,3.14159265358979,-9)", "3|c(7)|c(foo,bar)", "4|c(9,10)|c(TRUE,TRUE,FALSE)")) -test(1736.06, capture.output(fwrite(DT, sep='|', sep2=c("{",",","}"), logicalAsInt=TRUE)), - c("A|B|C", "1|{1,2,3,4,5,6,7,8,9,10}|{s,t,u,v,w}", - "2|{15,16,17,18}|{1.2,2.3,3.4,3.14159265358979,-9}", "3|{7}|{foo,bar}", "4|{9,10}|{1,1,0}"), - warning="logicalAsInt has been renamed logical01") +test(1736.06, fwrite(DT, sep='|', sep2=c("{",",","}"), logicalAsInt=TRUE), error="logicalAsInt has been renamed logical01") DT = data.table(A=c("foo","ba|r","baz")) test(1736.07, capture.output(fwrite(DT,na="")), c("A","foo","ba|r","baz")) # no list column so no need to quote test(1736.08, capture.output(fwrite(DT)), c("A","foo","ba|r","baz")) @@ -15957,8 +15954,7 @@ DT[ , z := 0L] test(2074.31, dcast(DT, V1 ~ z, fun.aggregate=eval(quote(length)), value.var='z'), data.table(V1=c('a', 'b'), `0`=2:1,key='V1')) -# fwrite both logical args -test(2074.32, fwrite(DT, logical01=TRUE, logicalAsInt=TRUE), error="logicalAsInt has been renamed") +# 2074.32 tested that setting both logical01 and logicalAsInt errored; no longer relevant # merge.data.table test(2074.33, merge(DT, DT, by.x = 1i, by.y=1i), error="A non-empty vector of column names is required") diff --git a/man/fwrite.Rd b/man/fwrite.Rd index ec23729c3..6cef5ec0a 100644 --- a/man/fwrite.Rd +++ b/man/fwrite.Rd @@ -11,8 +11,8 @@ fwrite(x, file = "", append = FALSE, quote = "auto", eol = if (.Platform$OS.type=="windows") "\r\n" else "\n", na = "", dec = ".", row.names = FALSE, col.names = TRUE, qmethod = c("double","escape"), - logical01 = getOption("datatable.logical01", FALSE), - logicalAsInt = logical01, # deprecated + logical01 = getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS + logicalAsInt = NULL, # deprecated scipen = getOption('scipen', 0L), dateTimeAs = c("ISO","squash","epoch","write.csv"), buffMB = 8L, nThread = getDTthreads(verbose),