View source: R/blockcv2rsample.R
blockcv2rsample | R Documentation |
blockCV
to an rsample
objectThis function converts objects created with blockCV
to rsample
objects
that can be used by tidysdm
. BlockCV provides more sophisticated sampling
options than the spatialsample
library. For example, it is possible to
stratify the sampling to ensure that presences and absences are evenly
distributed among the folds (see the example below).
blockcv2rsample(x, data)
x |
a object created with a |
data |
the |
Note that currently only objects of type cv_spatial
and cv_cluster
are
supported.
an rsample
object
library(blockCV)
points <- read.csv(system.file("extdata/", "species.csv",
package = "blockCV"
))
pa_data <- sf::st_as_sf(points, coords = c("x", "y"), crs = 7845)
sb1 <- cv_spatial(
x = pa_data,
column = "occ", # the response column to balance the folds
k = 5, # number of folds
size = 350000, # size of the blocks in metres
selection = "random", # random blocks-to-fold
iteration = 10
) # find evenly dispersed folds
sb1_rsample <- blockcv2rsample(sb1, pa_data)
class(sb1_rsample)
autoplot(sb1_rsample)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.