<div dir="ltr">I think you want<div><br></div><div>DT[,(newName):=do.call(paste,c(list(sep="_"),.SD)),.SDcols=colNames]<br></div><div><br></div><div>This is probably the sort of thing that would come naturally after studying all the vignettes and such on the site: <a href="https://github.com/Rdatatable/data.table/wiki/Getting-started">https://github.com/Rdatatable/data.table/wiki/Getting-started</a> Dunno that you want to be sending so much stuff to everyone on a mailing list. Your call, though.</div><div><br></div><div>--Frank</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 23, 2015 at 3:13 PM, statquant3 <span dir="ltr"><<a href="mailto:statquant@outlook.com" target="_blank">statquant@outlook.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">R) data.table(x=letters[1:5],y=rnorm(5),z=LETTERS[1:5])<br>
x y z<br>
1: a 0.5551301186 A<br>
2: b 0.1092535710 B<br>
3: c -2.4319115661 C<br>
4: d 1.6915588561 D<br>
5: e -1.5163715976 E<br>
<br>
colNames = c('y','z')<br>
newName = 't'<br>
<br>
How do I add a column 't' such that t:=paste(y,x,sep='_')<br>
<br>
x y z t<br>
1: a 0.5551301186 A 0.5551301186_A<br>
2: b 0.1092535710 B 0.1092535710_B<br>
3: c -2.4319115661 C ...<br>
4: d 1.6915588561 D ...<br>
5: e -1.5163715976 E ...<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://r.789695.n4.nabble.com/What-s-the-trick-to-paste-several-columns-together-in-one-tp4710266.html" rel="noreferrer" target="_blank">http://r.789695.n4.nabble.com/What-s-the-trick-to-paste-several-columns-together-in-one-tp4710266.html</a><br>
Sent from the datatable-help mailing list archive at Nabble.com.<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" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br>
</blockquote></div><br></div></div>