[datatable-help] What's the trick to paste several columns together in one

statquant3 statquant at outlook.com
Thu Jul 23 21:13:32 CEST 2015


R) data.table(x=letters[1:5],y=rnorm(5),z=LETTERS[1:5])
    x                     y  z
1: a  0.5551301186 A
2: b  0.1092535710 B
3: c -2.4319115661 C
4: d  1.6915588561 D
5: e -1.5163715976 E

colNames = c('y','z')
newName = 't'

How do I add a column 't' such that t:=paste(y,x,sep='_')

    x                     y  z t
1: a  0.5551301186 A 0.5551301186_A
2: b  0.1092535710 B 0.1092535710_B
3: c -2.4319115661 C ...
4: d  1.6915588561 D ...
5: e -1.5163715976 E ...




--
View this message in context: http://r.789695.n4.nabble.com/What-s-the-trick-to-paste-several-columns-together-in-one-tp4710266.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list