[datatable-help] Unexpected behavior in setnames()

Eduard Antonyan eduard.antonyan at gmail.com
Fri Nov 1 22:59:57 CET 2013


Having duplicate names is allowed and not that unusual in data.table
framework, so there is no need to signal anything here.

A different question is whether there should be a warning here:

  dt = data.table(a = 1, a = 2)
  dt[, a]

and I think that'd be a pretty good FR to have.


On Fri, Nov 1, 2013 at 4:49 PM, Alexandre Sieira <alexandre.sieira at gmail.com
> wrote:

> I found this behavior during a debugging session:
>
> > d = data.table(a=1, b=2, c=3)
> > setnames(d, "a", "b")
> > d
>    b b c
> 1: 1 2 3
>
> Shouldn’t setnames() check if the new column names already exist before
> renaming, and signal an error or at least a warning if they do?
>
> --
> Alexandre Sieira
> CISA, CISSP, ISO 27001 Lead Auditor
>
> "The truth is rarely pure and never simple."
> Oscar Wilde, The Importance of Being Earnest, 1895, Act I
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20131101/7f419cd2/attachment.html>


More information about the datatable-help mailing list