Learn R Programming

bioLeak (version 0.2.0)

as_rsample: Convert LeakSplits to an rsample resample set

Description

Convert LeakSplits to an rsample resample set

Usage

as_rsample(x, data = NULL, ...)

Value

An rsample rset object compatible with tidymodels workflows. The returned object is a tibble with class rset containing:

splits

List-column of rsplit objects, each with analysis (training indices) and assessment (test indices).

id

Character column with fold identifiers (e.g., "Fold1").

id2

Character column with repeat identifiers (e.g., "Repeat1") when multiple repeats are present; otherwise absent.

The object also carries attributes for group, batch,

study, time (when available from the original LeakSplits), and bioLeak_mode indicating the original splitting mode. This allows the splits to be used with tune::tune_grid(), rsample::fit_resamples(), and other tidymodels functions.

Arguments

x

LeakSplits object created by [make_split_plan()].

data

Optional data.frame used to populate rsample splits. When NULL, the stored `coldata` from `x` is used (if available).

...

Additional arguments passed to methods (unused).

Examples

Run this code
if (requireNamespace("rsample", quietly = TRUE)) {
  df <- data.frame(
    subject = rep(1:10, each = 2),
    outcome = rbinom(20, 1, 0.5),
    x1 = rnorm(20),
    x2 = rnorm(20)
  )
  splits <- make_split_plan(df, outcome = "outcome",
                        mode = "subject_grouped", group = "subject", v = 5)
  rset <- as_rsample(splits, data = df)
}

Run the code above in your browser using DataLab