<wanr <at> ucalgary.ca> writes:

: source vector = (1,2)
: the length of the target vector = 3
:  
: solution2: as.matrix(expand.grid(1:2, 1:2, 1:2)) almost implements what I 
: need. 
: 
: However, in my case, the length of the target vector is not fixed in 
: advance. For example, the output might be 11111, 11112, and etc coming from 
: the source vector (1,2).

If the only problem with that solution is that the length is not a parameter
then you could use this variation of it:

   as.matrix(do.call("expand.grid", rep(list(1:2),3)))

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to