make.spatial.folds: Partition data into k spatially blocked folds for cross...

View source: R/make.spatial.folds.R

make.spatial.foldsR Documentation

Partition data into k spatially blocked folds for cross validation

Description

This function takes in a data frame containing coordinates and creates a spatially blocked set of k folds.

Usage

make.spatial.folds(data, rangeX, rangeY, k = 5, coord.names = c("x", "y"))

Arguments

data

a data frame with columns coord.names to be split into spatial k folds.

rangeX

a vector of length 2 denoting the range of the horizontal coordinate. If missing this will be obtained from data - note that this assumes the region of interest is completely represented by points in the data frame provided.

rangeY

a vector of length 2 denoting the range of the vertical coordinate. If missing this will be obtained from data - note that this assumes the region of interest is completely represented by points in the data frame provided.

k

an integer denoting the number of folds. Default is 5.

coord.names

a vector of length two describing the column names of the horizontal and vertical coordinates in data in this order. Default is "x" and "y" respectively.

Value

a vector of length nrow(data) with integers denoting the fold into which each point falls.

Examples

#' # Get the gorilla nesting data
dat <- gorillas

# create spatial CV folds
dat$fold <- make.spatial.folds(dat)

# view the folds
table(dat$fold)

ElliotDovers/scampr documentation built on March 17, 2024, 3:27 p.m.