View source: R/borg_wrappers.R
| borg_initial_split | R Documentation |
A guarded version of rsample::initial_split() that checks for
temporal ordering when time structure is specified.
borg_initial_split(
data,
prop = 3/4,
strata = NULL,
time = NULL,
coords = NULL,
groups = NULL,
target = NULL,
...
)
data |
A data frame. |
prop |
Numeric. Proportion of data for training. Default: 0.75. |
strata |
Character. Column name for stratification. |
time |
Character. Time column - if provided, ensures chronological split. |
coords |
Character vector. Coordinate columns for spatial check. |
groups |
Character. Group column for clustered check. |
target |
Character. Target variable. |
... |
Additional arguments passed to |
When time is specified, this function ensures the split respects
temporal ordering (training data comes before test data). For spatial data,
it warns if random splitting may cause issues.
An rsplit object.
if (requireNamespace("rsample", quietly = TRUE)) {
# Temporal data - ensures chronological split
ts_data <- data.frame(
date = seq(as.Date("2020-01-01"), by = "day", length.out = 100),
value = cumsum(rnorm(100))
)
split <- borg_initial_split(ts_data, prop = 0.8, time = "date")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.