Hello All,
sample() only sample on one variable x. But I'm interested in sampling
more than one variable without replacement.
Suppose I have 3 vectors x, y, z. I want to draw samples from all
three vectors such that the combination of the three elements in each
draw is not the same as any
thmsfuller...@gmail.com wrote:
Hello All,
sample() only sample on one variable x. But I'm interested in sampling
more than one variable without replacement.
Suppose I have 3 vectors x, y, z. I want to draw samples from all
three vectors such that the combination of the three elements in each
This might help, depending on your exact needs:
v1 - sample(letters[1:2], 10, replace=TRUE)
v2 - sample(letters[3:4], 10, replace=TRUE)
v3 - sample(letters[5:6], 10, replace=TRUE)
aa - data.frame(v1=v1, v2=v2, v3=v3)
aa
v1 v2 v3
1 a d e
2 a d e
3 a c e
4 b d e
5 b d f
On Sun, 2010-05-23 at 00:56 -0700, dusadrian wrote:
This might help, depending on your exact needs:
v1 - sample(letters[1:2], 10, replace=TRUE)
v2 - sample(letters[3:4], 10, replace=TRUE)
v3 - sample(letters[5:6], 10, replace=TRUE)
aa - data.frame(v1=v1, v2=v2, v3=v3)
And now is simple,
4 matches
Mail list logo