<div dir="ltr">I think we should have a warning iff it is not a "clean" recycle (ie, the set gets cut off)<div><br></div><div>In other words </div><div><br></div><div> if (length(longer) %% length(shorter) != 0)</div>
<div> warning()</div><div><br></div><div><br><div class="gmail_extra"><br clear="all"><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><div style="font-size:13px">
Ricardo Saporta</div><div style="font-size:13px">Graduate Student, Data Analytics</div><div style="font-size:13px"><span style="font-size:13px">Rutgers University, New Jersey</span></div><div style="font-size:13px"><span style="font-size:13px">e: </span><a href="mailto:saporta@rutgers.edu" style="color:rgb(17,85,204);font-size:13px" target="_blank">saporta@rutgers.edu</a></div>
<div><br></div></div></div>
<br><br><div class="gmail_quote">On Mon, Oct 21, 2013 at 2:18 PM, Arunkumar Srinivasan <span dir="ltr"><<a href="mailto:aragorn168b@gmail.com" target="_blank">aragorn168b@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<span style="color:rgb(34,34,34);font-family:arial,sans-serif">Hi all,</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">
Here's the link to #4990: <a href="https://r-forge.r-project.org/tracker/index.php?func=detail&aid=4990&group_id=240&atid=975" style="color:rgb(17,85,204)" target="_blank">https://r-forge.r-<u></u>project.org/tracker/index.php?<u></u>func=detail&aid=4990&group_id=<u></u>240&atid=975</a><div style="width:16px;min-height:16px;display:inline-block">
</div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">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. </div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">For ex:</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">
dt <- data.table(a=rep(1:2, c(5,2)))</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">dt[, b := c(1,2,3), by=a]<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">
# creates warning that RHS is of length 3 and LHS is of length 2 for a ==2.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif"><div>Warning message:</div><div>In `[.data.table`(dt, , `:=`(b, c(1, 2, 3)), by = a) :</div>
<div> RHS 1 is length 3 (greater than the size (2) of group 2). The last 1 element(s) will be discarded.</div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">
Other than that, there need not be any warning because it's being recycled. For example, </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">
x <- 1:5</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">x[c(TRUE, FALSE)]</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif"># [1] 1 3 5. </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">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.<br>
</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">What do you guys think?</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif">Arun</div></div><div><div><br></div></div>
<br>_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br></blockquote></div><br></div></div>
</div>