[datatable-help] #4990 regarding

Arunkumar Srinivasan aragorn168b at gmail.com
Mon Oct 21 20:18:48 CEST 2013


Hi all,

Here's the link to #4990: https://r-forge.r-project.org/tracker/index.php?func=detail&aid=4990&group_id=240&atid=975



I'm not sure there should be any warning here. A warning message is created in `:=` if the RHS that's assigned is "bigger" in length than the LHS. 

For ex:

dt <- data.table(a=rep(1:2, c(5,2)))
dt[, b := c(1,2,3), by=a]

# creates warning that RHS is of length 3 and LHS is of length 2 for a ==2.
Warning message:
In `[.data.table`(dt, , `:=`(b, c(1, 2, 3)), by = a) :
  RHS 1 is length 3 (greater than the size (2) of group 2). The last 1 element(s) will be discarded.


Other than that, there need not be any warning because it's being recycled. For example, 

x <- 1:5
x[c(TRUE, FALSE)]
# [1] 1 3 5. 

Here, the number of elements of x are odd, but the recycling produces no warning. It may not exactly be the same issue, but to give an idea of silent recycling.

What do you guys think?

Arun

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20131021/5236815d/attachment.html>


More information about the datatable-help mailing list