I am happily using the data.table
package in R for passing large objects by reference. However, the following does not work:
addNewColumn = function(dataTable) {
dataTable[, newCol:=1]
return(0)
}
x = data.table(
id = c(11,22,33),
data=c(99,99,99)
)
file.remove("x.Rdata")
saveRDS(x, file="x.Rdata")
y = readRDS("x.Rdata")
print(class(y))
res = addNewColumn(y)
although class(y)
gives data.table
(and data.frame
). I.e. it seems that not all the class information is stored on disk and/or recovered from disk...
I am not sure whether I use the latest versions of R and the data.table package but I installed them just a few days ago...
I also discovered that using y = data.table(readRDS("x.Rdata"))
instead of y = readRDS("x.Rdata")
makes it work again but this statement seems to be senseless since I am casting something to a data.table
that already is a data.table
.
Best, and thanks for this nice package!!
FW