[R] Sampling problems

Sarah Goslee sarah.goslee at gmail.com
Wed Mar 7 21:04:39 CET 2012

You could make a vector containing the number of TRUE values that
makes up 80% of your data, and the number of FALSE values that makes
up 20% of your data. Use sample() to reorder it, then use it to divide
your dataset.

If you had provided a reproducible example, I could write you code.


On Wed, Mar 7, 2012 at 11:41 AM, Oritteropus <lucasantini85 at hotmail.com> wrote:
> Hi,
> I need to sample randomly my dataset for 1000 times. The sample need to be
> the 80%. I know how to do that, my problem is that not only I need the 80%,
> but I also need the corresponding 20% each time. Is there any way to do
> that?
> Alternatively, I was thinking to something like setdiff () function to
> compare my 80% sample to the original dataset and obtain the corresponding
> 20%, unfortunately setdiff works just for vectors, do you know a similar
> function for dataframes?
> Thanks

Sarah Goslee

More information about the R-help mailing list