[R] drawing samples based on a matching variable
Michael Bedward
michael.bedward at gmail.com
Wed Sep 29 03:50:06 CEST 2010
On 29 September 2010 09:47, Remko Duursma wrote:
>
>
> How about:
>
> y[y[,2] %in% x.samp[,2],]
>
> gives you the subset of y where values in the second column are restricted
> to your sample from x.
>
> You can then sample from this matrix, if you need to...
Just saw this reply tangled up in another topic (at least in my inbox).
Yes, that gives all the rows of matrix y that contain a col 2 value in
the matrix sampled from x but still leaves a bit of leg work to do and
doesn't check that the sampling is actually possible.
Michael
More information about the R-help
mailing list