data(iris)
iris2 <- iris[c(1:50,51:80,101:120),]
# Proportions to be respected
table(iris2$Species)/nrow(iris2)
# Splitting
result <- splitf(iris2,iris2$Species,3)
# All subsets have the same size
lapply(result,nrow)
# And respect the initial proportions
lapply(result,function(x) table(x$Species)/nrow(x))
Run the code above in your browser using DataLab