Learn R Programming

S4DM (version 0.0.1)

stratify_random: Split data for k-fold spatially stratified cross validation

Description

Splitting tool for cross-validation

Usage

stratify_random(occurrence_sf, nfolds = NULL)

Value

Returns a sf dataframe containing fold designation for each point.

Arguments

occurrence_sf

a sf object containing occurrence records

nfolds

number of desired output folds.

Author

Cory Merow cory.merow@gmail.com

Details

See Examples.

Examples

Run this code
{

# load in sample data

 library(S4DM)
 library(terra)
 library(sf)

 # occurrence points
   data("sample_points")
   occurrences <- sample_points


 occurrences <- st_as_sf(x = occurrences,coords = c(1,2))


random_folds <- stratify_random(occurrence_sf = occurrences,
                               nfolds = 5)


}

Run the code above in your browser using DataLab