[datatable-help] Unexpected behavior in setnames()

Steve Lianoglou lianoglou.steve at gene.com
Fri Nov 8 21:56:33 CET 2013


Right, agreed.

On Fri, Nov 8, 2013 at 12:53 PM, Arunkumar Srinivasan
<aragorn168b at gmail.com> wrote:
> Sorry, forget the j-value. For `.SDcols`, even when we provide integers
> (column numbers), internally, we compute the column name and subset to get
> `.SD`. And this'll have to change.
>
> Arun
>
> On Friday, November 8, 2013 at 9:47 PM, Steve Lianoglou wrote:
>
> On Fri, Nov 8, 2013 at 12:45 PM, Arunkumar Srinivasan
> <aragorn168b at gmail.com> wrote:
>
> Oh I can certainly agree with that. I guess we'll have to make some changes
> to the code to use index based subsetting when .SDcols or j-value is number
> then.
>
>
> Not sure what you mean by j-value -- the examples you gave didn't
> compute on the .SD, it just returned it.
>
> I think if there is a `j` expression that computes on an .SD that has
> duplicated colnames, I think we just stop().
>
> Or did you mean something else?
>
> -steve
>
> On Friday, November 8, 2013 at 9:41 PM, Steve Lianoglou wrote:
>
> 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
>
>
>
> _______________________________________________
> 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
>
>
>
>
> --
> Steve Lianoglou
> Computational Biologist
> Bioinformatics and Computational Biology
> Genentech
>
>
>
> _______________________________________________
> 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



-- 
Steve Lianoglou
Computational Biologist
Bioinformatics and Computational Biology
Genentech


More information about the datatable-help mailing list