[datatable-help] Unexpected behavior in setnames()

Steve Lianoglou lianoglou.steve at gene.com
Fri Nov 8 21:41:19 CET 2013


My gut reaction is:

On Fri, Nov 8, 2013 at 12:37 PM, Arunkumar Srinivasan
<aragorn168b at gmail.com> wrote:
> Sure, here's an example of what I was trying to explain:
>
> Suppose:
> DT <- data.table(x=1:5, y=1:5, x=6:10)
>
> Then,
>
> DT[, c(1,3), with=FALSE] # gives correct subset

This is "OK", we just do what the user asks, here, as they are being
very specific.

> DT[, c("x", "x"), with=FALSE] # gives column 1 twice - wrong

stop() -- we don't try to disambiguate (even if it "seems" specific)

> DT[, .SD, .SDcols=c("x", "x")] # gives column 1 twice - wrong result

stop()

Also stop() on DT[, ..., .SDcols="x"]

> DT[, .SD, .SDcols=c(1,3)] # gives column 1 twice - wrong result - but

Do what the user asks for.

No?

-steve

-- 
Steve Lianoglou
Computational Biologist
Bioinformatics and Computational Biology
Genentech


More information about the datatable-help mailing list