Re: [R] all combinations of the elements of two vectors

2011-08-29 Thread Campbell, Desmond
combinations of the elements of two vectors Hi Dear R-help readers, I'm sure this problem has been answered but I can't find the solution. I have two vectors v1 - c(a,b) v2 - c(1,2,3) I want an easy way to produce every possible combination of v1, v2 elements Ie I want to produce c(a1

Re: [R] all combinations of the elements of two vectors

2011-08-29 Thread David Winsemius
[mailto:petr.pi...@precheza.cz] Sent: 29 August 2011 07:24 To: Campbell, Desmond Cc: r-help@R-project.org Subject: Odp: [R] all combinations of the elements of two vectors Hi Dear R-help readers, I'm sure this problem has been answered but I can't find the solution. I have two vectors v1 - c(a,b) v2 - c

[R] all combinations of the elements of two vectors

2011-08-27 Thread Campbell, Desmond
Dear R-help readers, I'm sure this problem has been answered but I can't find the solution. I have two vectors v1 - c(a,b) v2 - c(1,2,3) I want an easy way to produce every possible combination of v1, v2 elements Ie I want to produce c(a1,a2,a3, b1,b2,b3) regards Desmond Desmond Campbell Dept

Re: [R] all combinations of the elements of two vectors

2011-08-27 Thread Jorge I Velez
Hi Desmond, You might try sort(apply(expand.grid(v1, v2), 1, paste, collapse = , sep = )) [1] a1 a2 a3 b1 b2 b3 HTH, Jorge On Sat, Aug 27, 2011 at 12:54 PM, Campbell, Desmond wrote: Dear R-help readers, I'm sure this problem has been answered but I can't find the solution. I have two

Re: [R] all combinations of the elements of two vectors

2011-08-27 Thread Daniel Malter
x-letters[1:3] y-1:3 d-expand.grid(x,y) g-apply(d,1,function(x) paste(x[1],x[2],sep=)) HTH, Daniel Campbell, Desmond-2 wrote: Dear R-help readers, I'm sure this problem has been answered but I can't find the solution. I have two vectors v1 - c(a,b) v2 - c(1,2,3) I want an easy way

Re: [R] all combinations of the elements of two vectors

2011-08-27 Thread Campbell, Desmond
:19 To: Campbell, Desmond Cc: r-help@R-project.org Subject: Re: [R] all combinations of the elements of two vectors Hi Desmond, You might try sort(apply(expand.grid(v1, v2), 1, paste, collapse = , sep = )) [1] a1 a2 a3 b1 b2 b3 HTH, Jorge On Sat, Aug 27, 2011 at 12:54 PM, Campbell, Desmond