0

I'm developing a package that uses data.table, but when I call certain data.table functions, such as DT[, ..colnames] or DT[grepl("foo", col)] or DT[, .(colname)] I get errors like: "colnames not found" or "could not find function "."". These errors are being called from data.frame so I guess when R looks for the functions, it's looking for them inside data.frame instead of data.table. When I run class(DT), I get "data.table" "data.frame"

I also tried DT[, data.table::.(colname)] but get the error that '.' is not an exported object from namespace:data.table.

I haven't run into this behavior outside of the context of package development. Can someone provide me with some advice?

asahi
  • 2,991
  • 2
  • 16
  • 17

1 Answers1

0

Per the comments, the solution was to import data.table in both DESCRIPTION and NAMESPACE. I also found this vignette to be helpful - https://cran.r-project.org/web/packages/data.table/vignettes/datatable-importing.html

This resource was also helpful: https://r-pkgs.org/dependencies-mindset-background.html#sec-dependencies-NAMESPACE-file

asahi
  • 2,991
  • 2
  • 16
  • 17