<div dir="ltr">DT[, y] returning a vector is I think the only correct behavior, given the understanding of j-expression as something evaluated in the DT environment. If they want a data.table they should simply use DT[, list(y)] or DT[, data.table(y)].<div>
<br></div><div>I haven't thought about DT[, "y", with = FALSE] before as I pretty much never use that form, but I see an argument for it staying as is, because "y" and c("y") are the same and since we all presumably agree that DT[, c("y", "z"), with = FALSE] should return a data.table. If DT[, c("y"), with = FALSE] returned a different type that would mean inconsistent return types which makes life much harder for users (as evidenced by the periodic drop=FALSE questions that come up on SO).</div>
<div><br></div><div>Going back to DT[, y], note that y and list(y) actually produce *different* results (in e.g. base_env), so there is no type consistency issue there between DT[, y] and DT[, list(y, z)].</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Nov 14, 2013 at 6:09 AM, 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>
Hi everybody,
</div><div><br></div><div>It'd be nice if you could weigh-in on the bug report filed by Bill here: </div><div><a href="https://r-forge.r-project.org/tracker/index.php?func=detail&aid=5100&group_id=240&atid=975" target="_blank">https://r-forge.r-project.org/tracker/index.php?func=detail&aid=5100&group_id=240&atid=975</a></div>
<div><br></div><div>The gist of it is:</div><div><br></div><div>require(data.table)</div><div>DT <- data.table(x=1:5, y=6:10, z=11:15)</div><div>DT[, y] # returns a vector</div><div>DT[, "y", with=FALSE] # returns a data.table</div>
<div><br></div><div>The question from the bug report basically is: "why is that in the first case, 'j' has only one column and we get a vector, but in the second case, we get a data.table?"</div><div><br>
</div><div>My question is: Is this behaviour okay or do you prefer that the first one returns a data.table as well or the second one (with "with=FALSE") returns a vector?</div>
<div><div><br></div><div>Thank you,</div><div>Arun</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>