apply(expand.grid(x, y, z, stringsAsFactors=F), 1, paste, collapse=' ')
On Wed, Jan 4, 2012 at 8:32 AM, jeremy <jeremynamer...@gmail.com> wrote: > Hi all, > > I'm trying to combine exhaustively several character arrays in R like: > x=c("one","two","three") > y=c("yellow","blue","green") > z=c("apple","cheese") > > in order to get concatenation of > > x[1] y[1] z[1] ("one yellow apple") > x[1] y[1] z[2] ("one yellow cheese") > x[1] y[2] z[1]("one blue apple") > ... > x[length(x)] y[length(y)] z[length(z)] ("three green cheese") > > Anyone has a solution ? > Thank in advance > > -- > View this message in context: > http://r.789695.n4.nabble.com/Combining-characters-tp4261888p4261888.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > [[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.