[datatable-help] #4990 regarding

Arunkumar Srinivasan aragorn168b at gmail.com
Wed Oct 23 22:39:48 CEST 2013


Ricardo, 

Thanks for the reply. Yes I agree. Eddi pointed out that, dt[, x := c(1:2)] when dt! for example! has a column y of length 5 will give a warning that it did not completely recycle. But when used with "by" it does not. This is obviously a bug. I will fix it to add the same warning for "by".

Arun.

Sent from my iPad

> On 23.10.2013, at 22:31, Ricardo Saporta <saporta at scarletmail.rutgers.edu> wrote:
> 
> I think we should have a warning  iff  it is not a "clean" recycle  (ie, the set gets cut off)
> 
> In other words 
> 
>   if (length(longer) %% length(shorter) != 0)
>      warning()
> 
> 
> 
> Ricardo Saporta
> Graduate Student, Data Analytics
> Rutgers University, New Jersey
> e: saporta at rutgers.edu
> 
> 
> 
>> On Mon, Oct 21, 2013 at 2:18 PM, Arunkumar Srinivasan <aragorn168b at gmail.com> wrote:
>> 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
>> 
>> 
>> _______________________________________________
>> datatable-help mailing list
>> datatable-help at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20131023/11eae525/attachment-0001.html>


More information about the datatable-help mailing list