[datatable-help] Over-writing factors

Damian Betebenner dbetebenner at nciea.org
Thu Sep 8 21:27:32 CEST 2011


Not sure whether the following is an intended behavior with data.table. Perhaps it is something idiosyncratic with factors.
It is different than what one gets with data.frame

test.df <- data.frame(X=letters[1:10], Y=rnorm(10))
test.dt <- data.table(X=letters[1:10], Y=rnorm(10))

test.df$X <- "Something Different"
test.dt$X <- "Something Different"
Error in `[<-.data.table`(x, j = name, value = value) :
  Some or all RHS not present in factor column levels


test.df <- data.frame(X=letters[1:10], Y=rnorm(10))
test.dt <- data.table(X=letters[1:10], Y=rnorm(10))

test.df[["X"]] <- "Something Different"
test.dt[["X"]] <- "Something Different"




Damian Betebenner
Center for Assessment
PO Box 351
Dover, NH   03821-0351

Phone (office): (603) 516-7900
Phone (cell): (857) 234-2474
Fax: (603) 516-7910

dbetebenner at nciea.org<mailto:dbetebenner at nciea.org>
www.nciea.org<http://www.nciea.org/>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20110908/f529ef25/attachment.htm>


More information about the datatable-help mailing list