Hi. Use paste(... , sep="_") to create a new variable, then data.frame() to join them.
Note that you have to name the columns explicitly; the default names are long for my tastes. HTH rksh > a <- data.frame(V1=1:3,V2=letters[1:3],V3=3:1,V4=100:102) > a V1 V2 V3 V4 1 1 a 3 100 2 2 b 2 101 3 3 c 1 102 > data.frame(n1=a$V1,n2=paste(a$V2,a$V3,sep="_"),n4=a$V4) n1 n2 n4 1 1 a_3 100 2 2 b_2 101 3 3 c_1 102 > On 27 Feb 2007, at 11:31, Aimin Yan wrote: > I have a data set like this > >> head(data.1A24_aa_model) > V1 V2 V3 V4 V5 V6 > 1 1A24 MODEL 1 ALA 1 84.47 > 2 1A24 MODEL 1 GLN 2 63.06 > 3 1A24 MODEL 1 TYR 3 107.72 > 4 1A24 MODEL 1 GLU 4 54.36 > 5 1A24 MODEL 1 ASP 5 67.01 > 6 1A24 MODEL 1 GLY 6 999.00 > > I want to change this to the following format: > > V1 V2 V3 V4 V5 > 1 1A24 MODEL 1 ALA _1 84.47 > 2 1A24 MODEL 1 GLN _2 63.06 > 3 1A24 MODEL 1 TYR _3 107.72 > 4 1A24 MODEL 1 GLU _4 54.36 > 5 1A24 MODEL 1 ASP _5 67.01 > 6 1A24 MODEL 1 GLY _6 999.00 > > anyone know how to do this? > > Aimin > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
