pkgdown/mathjax-config.html

Skip to contents

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().

Value

An rsplit object.

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.

Examples

if (FALSE) { # \dontrun{
# 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")
} # }