Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

unique(rbind(ky_40,ky))[-(1:nrow(ky_40)),]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top