Do you want to sample 30 observations from 100 with or without
replacement ?
If you want to sample without replacement and 'x' is a vector or index
of data (useful for matrix indexing), then try
xsamp.mat <- replicate( 200, sample(x, 30) )
where the columns of xsamp.mat represent the sampled values or index.
If you want to sample with replacement, the try
xsamp.mat <- replicate( 200, sample(x, 30, replace=TRUE) )
or
xsamp.mat <- matrix( sample(x, 30*200, replace=TRUE), ncol=200 )
For more information, see 'help(sample)'.
Regards, Adai
On Mon, 2006-08-28 at 23:20 -0700, Shola Adeyemi wrote:
> Dear Allstats,
>
> Please I have a data of size 100 imported to R and I need to sample from this data. That is, take 200 random samples each of size 30 from the data. Please how do I do this in R?
>
> Your urgent reply will be highly appreciated.
>
> Thank you.
>
> Shollerss
>
>
> ---------------------------------
> Stay in the know. Pulse on the new Yahoo.com. Check it out.
>
|