Learn R Programming

tidysdm (version 1.0.0)

spatial_initial_split: Simple Training/Test Set Splitting for spatial data

Description

spatial_initial_split creates a single binary split of the data into a training set and testing set. All strategies from the package spatialsample are available; a random split from that strategy will be used to generate the initial split.

Usage

spatial_initial_split(data, prop, strategy, ...)

Value

An rsplit object that can be used with the rsample::training and rsample::testing functions to extract the data in each split.

Arguments

data

A dataset (data.frame or tibble)

prop

The proportion of data to be retained for modelling/analysis.

strategy

A sampling strategy from spatialsample

...

parameters to be passed to the strategy

Examples

Run this code
set.seed(123)
block_initial <- spatial_initial_split(boston_canopy,
  prop = 1 / 5, spatial_block_cv
)
testing(block_initial)
training(block_initial)

Run the code above in your browser using DataLab