[R] How to subset my data and at the same time keep the balance?

Sarah Goslee sarah.goslee at gmail.com
Mon Nov 19 18:26:55 CET 2012


I'm not sure what you mean by "balance", but you can use sample() to
randomly order the values 1:1000, then use the first 700 as row
indices for the first set, and the last 300 as the test set.

Sarah

On Mon, Nov 19, 2012 at 12:16 PM, Eddie Smith <eddieatr at gmail.com> wrote:
> Hi guys,
>
> I have 1000 rows of a dataset. In my analysis, I need 70% of the data,
> run my analysis and then use the remaining 30% to test my model.
>
> Could anybody kindly help me on this?
>
> Cheers
--
Sarah Goslee
http://www.functionaldiversity.org




More information about the R-help mailing list