split_data: Split Data Into Training and Test

Description Usage Arguments Value Examples

View source: R/split_data.R

Description

Split a data set into training and testing data.

Usage

1
2
3
4
5
6
7
split_data(data, n.train = 0.5, ...)

## S3 method for class 'data.frame'
split_data(data, n.train = 0.5, ...)

## Default S3 method:
split_data(data, n.train = 0.5, ...)

Arguments

data

A data.frame or vector.

n.train

An integer (number of) or proportion (proportion of) dictating how many observations to place in the training set.

...

ignored.

Value

Returns a named list of split data; a train data set and a test data set.

Examples

1
2
3
4
5
6
7
8
9
(split_dat <- split_data(mtcars))
split_dat$train
split_dat$test
split_data(mtcars, .8)

split_data(mtcars, 20)
split_data(LETTERS)
split_data(LETTERS, .4)
split_data(LETTERS, 10)

trinker/termco documentation built on Jan. 7, 2022, 3:32 a.m.