I want to subset 100 times a data frame that consists of 20 variables (continuous and categorical) in two parts that represent 70% and 30%. But I can do this with iris data set too as an example.
data(iris)
test.rows <- sample(1:nrow(iris), 105)
iris.70 <- iris[test.rows, ]
iris.30 <- iris[-test.rows, ]
This gives the data frames I want. But how can I do this 100 times and store the results somewhere to employ them later?
I have been trying
output <- list()
for(i in 1:surveyed100){
output[[i]] <- test.rows <- sample(1:nrow(surveyed100), 246)
}
But it tells me: numerical expression has 5 elements: only the first used.
I will appreciate your help.