Hi,

Try this,

apply(expand.grid(letters[1:3], letters[24:26]), 1, paste,collapse="")
[1] "ax" "bx" "cx" "ay" "by" "cy" "az" "bz" "cz"

?expand.grid

HTH,

baptiste

2009/12/14 Amelia Livington <amelia_living...@yahoo.com>:
>
> Dear R helpers,
>
> I am working on the scenario analysis pertaining to various interest rates. 
> In this connection I need to form the various combinations as under :
>
> Suppose I have two sets A = (a, b, c) and B = (x,y,z)
>
> Then I can easily form the cominations as
> (ax, ay, az, bx, by, bz, cx, cy, cz)
>
> However, if I have say 5 variables, then total no of possible combinations 
> will be 3^5 = 243.
> Thus, A = (a,b,c), B = (x, y, z), C = (l, m, n), D = (p,q,r), E = (s, t, u). 
> Then may be my possble combination will start as (a, x, l, p, s), then next 
> combination may be (a, x, l, p, u) and so on. The last combination (243rd in 
> this case) may be (c, z, n, r, u) or something like this.
>
> In R, is there any way to list all these 3^5 = 243 combinations?
>
> Amelia
>
>
>
>        [[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.

Reply via email to