<div>
Sure, here's an example of what I was trying to explain:
</div><div><br></div><div>Suppose: </div><div>DT <- data.table(x=1:5, y=1:5, x=6:10)</div><div><br></div><div>Then, </div><div><br></div><div>DT[, c(1,3), with=FALSE] # gives correct subset</div><div>DT[, c("x", "x"), with=FALSE] # gives column 1 twice - wrong</div><div><br></div><div>DT[, .SD, .SDcols=c("x", "x")] # gives column 1 twice - wrong result</div><div>DT[, .SD, .SDcols=c(1,3)] # gives column 1 twice - wrong result - but *should provide right result if "ambiguity" is the only concern.</div><div><br></div>
<div><div><br></div><div>Arun</div><div><br></div></div>
<p style="color: #A0A0A8;">On Friday, November 8, 2013 at 9:29 PM, Steve Lianoglou wrote:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div><blockquote type="cite"><div><div>Steve,</div><div>Maybe, but it's just getting started :) - we now have to decide what's</div><div>ambiguous!</div></div></blockquote><div><br></div><div>So close, yet so far ...</div><div><br></div><blockquote type="cite"><div><div>Ex: Is subsetting by column number considered ambiguous (By definition of</div><div>ambiguous, probably not)? But then it'd be inconsistent with subsetting when</div><div>column names are provided.. So, should we prioritise consistency over</div><div>function in this scenario?</div></div></blockquote><div><br></div><div>Sorry, can you provide examples of each?</div><div><br></div><div>I'd imagine doing anything by column number is unambiguous, but I'm</div><div>not sure how you can subset by column index and by column name in a</div><div>"similar" fashion.</div><div><br></div><div>I mean dt[[1]] should work no matter what, dt[['a']] would work only</div><div>if there is only one column named 'a' ... but I don't think this is</div><div>what you are talking about?</div><div><br></div><div>Sorry if I'm being obtuse,</div><div><br></div><div>-steve</div><div><br></div><div>-- </div><div>Steve Lianoglou</div><div>Computational Biologist</div><div>Bioinformatics and Computational Biology</div><div>Genentech</div></div></div></span>
</blockquote>
<div>
<br>
</div>