Reputation:
data(kyphosis)
ky<- kyphosis
By this I made a data set consisting of 40% of original one.
ky_40 <- ky[sample(1:nrow(ky), nrow(ky)*0.4,replace=FALSE),]
By this statement I want to make a data set consisting of 60% of the original one excluding
ky_40.
ky_the_others<- ???????
How can I make the last code?
Upvotes: 2
Views: 110
Reputation: 193517
Just move the sampling out of your extraction so you can refer to it again:
ky <- mtcars
## Here, I've moved the sampling out of your extraction
forty <- sample(1:nrow(ky), nrow(ky)*0.4,replace=FALSE)
## Now you can extract whatever you want
ky[ forty, ] # This will be the 40% of original dataset
ky[-forty, ] # This will be the remaining rows.
Upvotes: 4