Basically, because fastDummies Imports data.table but does not importFrom(data.table, ...) in its NAMESPACE, to be conservative data.table assumes that fastDummies is "unaware" of data.table[ semantics and dispatches to [.data.frame.
Where that code won't work under [.data.table. The data.table equivalent is:
.data[, !..char_cols]
# or
.data[, !char_cols, with = FALSE]
# or
.data[, .SD, .SDcols = !char_cols]
The solution is
Set .datatable.aware = TRUE anywhere in the package namespace
Edit [ usages to use [.data.table semantics where appropriate.
Happy to file a PR fixing this.
If [.data.frame usage is intentional, I'd recommend (1) using as.data.frame() or data.table::setDF() to make the use of [.data.frame more intentional/explicit or (2) defining .datatable.aware=FALSE in your namespace to make it clearer that this is intentional.
See https://cran.r-project.org/web/packages/data.table/vignettes/datatable-importing.html, relevant section "data.table in Imports but nothing imported"
Basically, because
fastDummies
Importsdata.table
but does notimportFrom(data.table, ...)
in its NAMESPACE, to be conservative data.table assumes thatfastDummies
is "unaware" ofdata.table
[
semantics and dispatches to[.data.frame
.That's evident e.g. here:
https://github.com/jacobkap/fastDummies/blob/1ff61812f314279706bebec7d4b1c28110f93eba/R/dummy_cols.R#L223
Where that code won't work under
[.data.table
. Thedata.table
equivalent is:The solution is
.datatable.aware = TRUE
anywhere in the package namespace[
usages to use[.data.table
semantics where appropriate.Happy to file a PR fixing this.
If
[.data.frame
usage is intentional, I'd recommend (1) usingas.data.frame()
ordata.table::setDF()
to make the use of[.data.frame
more intentional/explicit or (2) defining.datatable.aware=FALSE
in your namespace to make it clearer that this is intentional.