Description Usage Arguments Methods (by class) Examples
Generate cross-validation test-training sets from manually specified indices of observations in the test and and training sets.
1 2 3 4 5 6 7 |
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 |
test |
A list of integer vectors or an integer vector, with the indices of the test set.
If |
data.frame
: Partition a data frame into test and training sets by row.
grouped_df
: Partition a grouped data frame into test and training
sets by group.
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.