[R] How to do this "combination" ?

wanr@ucalgary.ca wanr at ucalgary.ca
Thu Sep 9 00:00:50 CEST 2004


Thanks David first.

Probably, David misunderstood my points.

source vector = (1,2)
the length of the target vector = 3

My expected "complete" outputs should be:
111, 112, 121, 122, 211, 212, 221, 222.

sample(c(1,2),3,replace=TRUE) just gives me one "randomly sampled" 
combination at a time. However, I need the whole list displayed above at a 
time.

Rui




More information about the R-help mailing list