<div>
Ricardo added a bug report here on this topic: <a href="https://r-forge.r-project.org/tracker/index.php?func=detail&aid=5008&group_id=240&atid=975">https://r-forge.r-project.org/tracker/index.php?func=detail&aid=5008&group_id=240&atid=975</a></div><div><div>But I don't think having duplicate names is an easy-to-implement concept. For ex:</div><div><br></div><div>dt <- data.table(x=1:3, x=4:6, y=c(1,1,2))</div><div>dt[, print(.SD), by=y]</div><div><div> x</div><div>1: 1</div><div>2: 2</div><div> x</div><div>1: 3</div></div><div><br></div><div>.SD loses the second "x". Also, some other questions become difficult to handle. Ex: </div><div><br></div><div><div>dt <- data.table(x=c(1,1,2,2), y=c(1,2,3,4), x=c(2,2,1,1))</div><div>dt[, list(x=x/x[1], y=y), by=x]</div></div><div><br></div><div>Which "x" should be choose for which operation?</div><div><br></div><div>Arun</div><div><br></div></div>
<p style="color: #A0A0A8;">On Friday, November 1, 2013 at 10:59 PM, Eduard Antonyan wrote:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div><div dir="ltr">Having duplicate names is allowed and not that unusual in data.table framework, so there is no need to signal anything here.<div><br></div><div>A different question is whether there should be a warning here:</div>
<div><br></div><div> dt = data.table(a = 1, a = 2)</div><div> dt[, a]</div><div><br></div><div>and I think that'd be a pretty good FR to have.</div></div><div><br><br><div>On Fri, Nov 1, 2013 at 4:49 PM, Alexandre Sieira <span dir="ltr"><<a href="mailto:alexandre.sieira@gmail.com" target="_blank">alexandre.sieira@gmail.com</a>></span> wrote:<br><blockquote type="cite"><div><div style="word-wrap:break-word"><div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
I found this behavior during a debugging session: </div><div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">
<div style="margin:0px">> d = data.table(a=1, b=2, c=3)</div><div style="margin:0px">> setnames(d, "a", "b")</div><div style="margin:0px">> d</div><div style="margin:0px"> b b c</div><div style="margin:0px">
1: 1 2 3</div><div style="margin:0px"><br></div><div style="margin:0px">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?</div></div><span><font color="#888888"><br>
<div><span style="font-family:helvetica,arial;font-size:13px"></span><div style="font-family:Helvetica;line-height:normal">-- </div><div style="font-family:Helvetica;line-height:normal"><span style="font-family:arial;font-size:small">Alexandre Sieira</span><br style="font-family:arial;font-size:small">
<span style="font-family:arial;font-size:small">CISA, CISSP, ISO 27001 Lead Auditor</span><br style="font-family:arial;font-size:small"><br style="font-family:arial;font-size:small"><span style="font-family:arial;font-size:small">"The truth is rarely pure and never simple."</span><br style="font-family:arial;font-size:small">
<span style="font-family:arial;font-size:small">Oscar Wilde, The Importance of Being Earnest, 1895, Act I</span></div></div></font></span></div><br>_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br></div></blockquote></div><br></div>
</div><div><div>_______________________________________________</div><div>datatable-help mailing list</div><div><a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a></div><div><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a></div></div></div></span>
</blockquote>
<div>
<br>
</div>