kfold_partition {enmpa}R Documentation

K-fold data partitioning

Description

Creates indices to partition available data into k equal-sized subsets or folds, maintaining the global proportion of presence-absences in each fold.

Usage

kfold_partition(data, dependent, k = 2, seed = 1)

Arguments

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.

Value

A list of vectors with the indices of rows corresponding to each fold.

Examples

# 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, ]

[Package enmpa version 0.1.8 Index]