resample_df: Generate subsamples from indices

Description Usage Arguments Value Methods (by class) Examples

Description

Generate subsamples from manually specified indices of observations in each subsample.

Usage

1
2
3
4
5
6
7
resample_df(data, ...)

## S3 method for class 'data.frame'
resample_df(data, samples, ...)

## S3 method for class 'grouped_df'
resample_df(data, samples, ...)

Arguments

data

A data frame

...

Arguments passed to methods

samples

A list of integer vectors or an integer vector, with the indices in each subsample.

Value

A data frame with rows for each subsample and the following columns:

train

A list of resample objects. Training sets.

test

A list of resample objects. Test sets.

.id

An integer vector of identifiers

Methods (by class)

Examples

1
2
3
4
5
6
library("dplyr")
# specify subsamples by a list of indices
resample_df(mtcars, samples = c(1:5, 5:10, 15:20))
resample_df(mtcars, samples = c(1:10, 1:15, 5:30))
# with grouped data frames, indices refer to groups
resample_df(group_by(mtcars, mpg), samples = list(c(1:2)))$sample

jrnold/resamplr documentation built on May 20, 2019, 1:05 a.m.