View source: R/kfold_partition.R
kfold_partition | R Documentation |
Creates indices to partition available data into k equal-sized subsets or folds, maintaining the global proportion of presence-absences in each fold.
kfold_partition(data, dependent, k = 2, seed = 1)
data |
data.frame or matrix containing at least two columns. |
dependent |
(character) name of column that contains the presence-absence records (1-0). |
k |
(numeric) the number of groups that the given data is to be split into. |
seed |
(numeric) integer value to specify an initial seed. Default = 1. |
A list of vectors with the indices of rows corresponding to each fold.
# example data
data <- data.frame(species = c(rep(0, 80), rep (1,20)),
variable1 = rnorm(100),
variable2 = rpois(100, 2))
# create partition indices
kfolds <- kfold_partition(data, dependent = "species", k = 2)
# data for partition 1
data[kfolds$Fold_1, ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.