[datatable-help] Problem with := in datatable 1.7.0

mhwaliji mhwaliji at gmail.com
Thu Oct 20 23:45:37 CEST 2011


I tried out the new version of data.table using the following command.

svn checkout svn://svn.r-forge.r-project.org/svnroot/datatable/pkg@373

However, I get the following error with :=.  Note that it set all the values
of y to 1, not just the rows selected.  Is this a new bug, or am I perhaps
retrieving from the wrong repository?

> DT <- data.table(x=rep(c(1, 2), each=5), y=11:20)
> DT[x == 1, y := x]
      x y
 [1,] 1 1
 [2,] 1 1
 [3,] 1 1
 [4,] 1 1
 [5,] 1 1
 [6,] 2 1
 [7,] 2 1
 [8,] 2 1
 [9,] 2 1
[10,] 2 1
Warning message:
In `[.data.table`(DT, x == 1, `:=`(y, x)) :
  Coerced numeric RHS to integer to match the column's type; may have
truncated precision. Either change the column to numeric first (by creating
a new numeric vector length 10 (nrows of entire table) yourself and
assigning that; i.e. 'replace' column), or coerce RHS to integer yourself
(e.g. 1L or as.integer) to make your intent clear (and for speed). Or, set
the column type correctly up front when you create the table and stick to
it, please.

Thanks,
Muhammad

--
View this message in context: http://r.789695.n4.nabble.com/Problem-with-in-datatable-1-7-0-tp3923534p3923534.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list