borg_initial_split: BORG-Guarded initial_split

View source: R/borg_wrappers.R

borg_initial_splitR Documentation

BORG-Guarded initial_split

Description

A guarded version of rsample::initial_split() that checks for temporal ordering when time structure is specified.

Usage

borg_initial_split(
  data,
  prop = 3/4,
  strata = NULL,
  time = NULL,
  coords = NULL,
  groups = NULL,
  target = NULL,
  ...
)

Arguments

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 rsample::initial_split().

Details

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.

Value

An rsplit object.

Examples


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")
}



BORG documentation built on March 20, 2026, 5:09 p.m.