crossv_df: Generate cross-validation test-training sets manually

Description Usage Arguments Methods (by class) Examples

Description

Generate cross-validation test-training sets from manually specified indices of observations in the test and and training sets.

Usage

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

## S3 method for class 'data.frame'
crossv_df(data, train = NULL, test = NULL, ...)

## S3 method for class 'grouped_df'
crossv_df(data, train = NULL, test = NULL, ...)

Arguments

data

A data frame

...

Arguments passed to methods

train

A list of integer vectors or an integer vector, with the indices of the training set. If train is NULL, then the training set is the complement of the test set.

test

A list of integer vectors or an integer vector, with the indices of the test set. If test is NULL, then the test set is the complement of the training set.

Methods (by class)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library("dplyr")

# test-training pairs can be specified by test sets
crossv_df(mtcars, train = list(1:5, 6:10))
# or by training sets
crossv_df(mtcars, train = list(1:20, 10:32))
# or by both (and they don't need to partition the observations)
crossv_df(mtcars,
          train = list(1:20, 10:32),
          test = list(21:32, 1:9))

# with grouped data frames, the indices refer to groups
crossv_df(group_by(mtcars, mpg), train = list(1L))$train

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