... or using the handy with() with(x,paste(n,l,sep="_"))
Slightly greater clarity and robustness, perhaps... -- Bert On Tue, Aug 21, 2012 at 9:24 AM, R. Michael Weylandt <michael.weyla...@gmail.com> wrote: > You don't need loops or apply with paste since it's vectorized: > > x <- data.frame(n = 1:5, l = letters[1:5], stringsAsFactors = FALSE) > > paste(x[,1], x[,2], sep = "_") > > Cheers, > Michael > > On Tue, Aug 21, 2012 at 10:57 AM, Chet Seligman <chet.selig...@gmail.com> > wrote: >> This works, where zz is a dataframe: >> >> for(i in 1:nrow(zz)) { >> zzz[i,1]<-paste(zz[i,1],zz[i,2],sep="_") >> } >> >> I would like to use "apply" to concatentate two columns of text along with >> a separator. >> How? >> >> Chet >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help@r-project.org 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. > > ______________________________________________ > R-help@r-project.org 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm ______________________________________________ R-help@r-project.org 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.