Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

make_train

Generate a variable used to selected a training sample


Description

Generate a variable used to selected a training sample

Usage

make_train(n = 0.7, nr = NULL, blocks = NULL, seed = 1234)

Arguments

n

Number (or fraction) of observations to label as training

nr

Number of rows in the dataset

blocks

A vector to use for blocking or a data.frame from which to construct a blocking vector

seed

Random seed

Value

0/1 variables for filtering

Examples

make_train(.5, 10)
make_train(.5, 10) %>% table()
make_train(100, 1000) %>% table()
make_train(.15, blocks = mtcars$vs) %>% table() / nrow(mtcars)
make_train(.10, blocks = iris$Species) %>% table() / nrow(iris)
make_train(.5, blocks = iris[, c("Petal.Width", "Species")]) %>% table()

radiant.data

Data Menu for Radiant: Business Analytics using R and Shiny

v1.3.12
AGPL-3 | file LICENSE
Authors
Vincent Nijs [aut, cre]
Initial release
2020-11-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.