I think currently it chooses the first "x", but it's definitely a good idea to add a warning there.
On Fri, Nov 1, 2013 at 5:51 PM, Arunkumar Srinivasan <[email protected]>wrote: > Ricardo added a bug report here on this topic: > https://r-forge.r-project.org/tracker/index.php?func=detail&aid=5008&group_id=240&atid=975 > But I don't think having duplicate names is an easy-to-implement concept. > For ex: > > dt <- data.table(x=1:3, x=4:6, y=c(1,1,2)) > dt[, print(.SD), by=y] > x > 1: 1 > 2: 2 > x > 1: 3 > > .SD loses the second "x". Also, some other questions become difficult to > handle. Ex: > > dt <- data.table(x=c(1,1,2,2), y=c(1,2,3,4), x=c(2,2,1,1)) > dt[, list(x=x/x[1], y=y), by=x] > > Which "x" should be choose for which operation? > > Arun > > On Friday, November 1, 2013 at 10:59 PM, Eduard Antonyan wrote: > > 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 < > [email protected]> 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 > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > > > _______________________________________________ > datatable-help mailing list > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > > >
_______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
