> t1 <- data.table(a=1:3,b=1/(1:3))
> t1[1,2]<- 99

Shouldn't this give an error?  With with=T (the default), this doesn't make
sense, and the resulting DT is not valid:

> t1
Error in data.table(lapply(x, function(x) { :
  every input must have at least one value, unless all columns are empty

In fact, I'm not sure how to modify an individual cell in a DT:

> t1 <- data.table(a=1:3,b=1/(1:3))
> t1[1,2,with=F]<- 99
Error in `[<-.data.table`(`*tmp*`, 1, 2, with = F, value = 99) :
  unused argument(s) (with = F)

On the other hand, you can apparently modify an entire column:

t1 <- data.table(a=1:3,b=1/(1:3))
> t1$b <- 11:13
> t1
     a  b
[1,] 1 11
[2,] 2 12
[3,] 3 13

And modifying a key column very sensibly makes it no longer a key:

> t2 <- data.table(a=1:3,b=1/(1:3),key="a")
> key(t2)
[1] "a"
> t2$a <- 11:13
> key(t2)
NULL
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to