apply(expand.grid(x, y, z, stringsAsFactors=F), 1, paste, collapse=' ')
On Wed, Jan 4, 2012 at 8:32 AM, jeremy 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 or
Try expand.grid() to create all the combinations. Then just collapse
them with paste():
apply(expand.grid(x, y, z), 1, paste, collapse = " ")
Cheers,
Josh
On Wed, Jan 4, 2012 at 8:32 AM, jeremy wrote:
> Hi all,
>
> I'm trying to combine exhaustively several character arrays in R like:
> x=c("
On Jan 4, 2012, at 10:32 AM, jeremy 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
? expand.grid
Michael
On Wed, Jan 4, 2012 at 10:32 AM, jeremy 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] ("o
Hi. You can use expand.grid here
expand.grid(x,y,z)
Andrija
On Wed, Jan 4, 2012 at 5:32 PM, jeremy 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 co
Hello,
If you want to apply the same procedure to all elements of an object, check
out the '*apply' functions.
In this case,
x=c("one","two","three")
y=c("yellow","blue","green")
z=c("apple","cheese")
lapply(x, function(x) paste(x, y))
gives a good picture of what you want to do, just transfo
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")
7 matches
Mail list logo