# \donttest{
if (requireNamespace("rsample", quietly = TRUE)) {
# Safe: no dependencies
data <- data.frame(x = rnorm(100), y = rnorm(100))
folds <- borg_vfold_cv(data, v = 5)
# Use auto_block to automatically switch to spatial CV:
spatial_data <- data.frame(
lon = runif(100, -10, 10),
lat = runif(100, -10, 10),
response = rnorm(100)
)
folds <- borg_vfold_cv(spatial_data, coords = c("lon", "lat"),
target = "response", auto_block = TRUE)
}
# }
Run the code above in your browser using DataLab