[R] How to subset my data and at the same time keep the balance?
Rui Barradas
ruipbarradas at sapo.pt
Mon Nov 19 18:25:25 CET 2012
Hello,
See the following example.
x <- matrix(rnorm(2000), ncol = 2)
idx <- sample(nrow(x), 0.7*nrow(x))
x2 <- x[idx, ]
nrow(x2) # 700
x3 <- x[-idx, ]
nrow(x3) # 300
Hope this helps,
Rui Barradas
Em 19-11-2012 17:16, Eddie Smith escreveu:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list