Skip to content
Prev 3287 / 7419 Next

subsetting in R

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