You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If some functions, own or third-party, resets all R options to what they were prior to loading data.table, then some data.table functions fail because querying those options result in NULL values. Imagine a function that reset all R options using on.exit() to protect against side effects from some rough function call setting, say, options(warn = 2).
Reproducible example
library(data.table)
## data.table optionsnames<- grep("^datatable", names(options()), value=TRUE)
dtopts<- options()[names]
a<- data.table()
## remove data.table optionsreset<- setNames(vector("list", length= length(dtopts)), names(dtopts))
options(reset)
b<- data.table()
#> Error in setalloccol(ans) : verbose must be TRUE or FALSE
Troubleshooting
The problem is that data.table::setalloccol() assumes that these R options are always set. For example,
args(data.table::setalloccol)
#> function (DT, n = getOption("datatable.alloccol"), verbose = getOption("datatable.verbose")) #> NULL
Suggestion
I'd like to argue that code should not make assumptions about R options being set, even for "internal" R options. My suggestions is to add defaults to all getOption(), e.g.
args(data.table::setalloccol)
#> function (DT, n = getOption("datatable.alloccol", 1024L), verbose = getOption("datatable.verbose", FALSE)) #> NULL
Issue
If some functions, own or third-party, resets all R options to what they were prior to loading data.table, then some data.table functions fail because querying those options result in
NULL
values. Imagine a function that reset all R options usingon.exit()
to protect against side effects from some rough function call setting, say,options(warn = 2)
.Reproducible example
Troubleshooting
The problem is that
data.table::setalloccol()
assumes that these R options are always set. For example,Suggestion
I'd like to argue that code should not make assumptions about R options being set, even for "internal" R options. My suggestions is to add defaults to all
getOption()
, e.g.FWIW, from:
it's clear your aware of this potential problem. Maybe this has already been discussion previously.
Session info
The text was updated successfully, but these errors were encountered: