I have a custom package but I'm having trouble using data.table inside functions. I've included data.table
in the Imports
file: Using data.table package inside my own package
If I save this funciton in the global enviroment it runs no-problem but now when called from the pacakge.
The error is:
Error in
:=
(shapeId, paste(shape1, shape3, sep = "-")) : Check that is.data.table(DT) == TRUE. Otherwise, := and:=
(...) are defined for use in j, once only and in particular ways. See help(":=")
However if I go into browser()
mode to where this problem occurs, I find that running is.data.table(res)
returns TRUE
:
For replication:
res = structure(list(shape1 = c("oh", "sd", "tx", "tx", "tx", "tx"),
shape3 = c("pike", "aurora", "kendall", "kendall", "kendall",
"kendall")), .Names = c("shape1", "shape3"), row.names = c(NA,
6L), class = c("data.table", "data.frame"))
and then run
res[, shapeId := paste(shape1, shape3, sep = '-')]
triggers the error . Even though
Browse[2]>is.data.table(res)
Browse[2]>TRUE