library(disdat)
train <- disPo("NSW")
## a single species
srsp1 <- subset(train, spid=="nsw01")
folds(srsp1, k = 5)
## all species
k = folds(train, k=5, by=train$spid)
## each group has the same number of records
##(except for adjustments if the number of records
## divided by k is not an integer)
table(k[train$spid=="nsw01"])
Run the code above in your browser using DataLab