[R-sig-eco] subsetting in R
Kristen Gorman
kgorman at sfu.ca
Tue Sep 18 23:56:00 CEST 2012
Dear all,
I have a dataset where I would like to take 2/3 of the data to build a model and test it on the remaining 1/3 of the dataset. In order to generate the 2/3 dataset I have the following code:
# 85 is .66 of 129 in order to generate random number for 2/3 dataset.
DataSet.Sub2.66<- DataSet.Sub2[sample(1:nrow(DataSet.Sub2), 85, replace=FALSE),]
Now, I would like to generate a separate dataset from the remaining 1/3 dataset not selected for the 2/3 dataset. Any ideas on how best to do this?
Thanks for any input,
Kristen
More information about the R-sig-ecology
mailing list