[R] apply question

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Tue Aug 21 18:23:04 CEST 2012


What is wrong with utilizing the vectorized nature of paste?

 zz[[1]] <- paste(zz[[1]],zz[[2]],sep="_")
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Chet Seligman <chet.seligman at 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 at 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.




More information about the R-help mailing list