Learn R Programming

emil (version 2.2.3)

pre_factor_to_logical: Convert factors to logical columns

Description

Factors will be converted to one logical column per level (or one fewer if a base level is specified).

Usage

pre_factor_to_logical(data, feature, base = 1L, drop = TRUE)

Arguments

Examples

Run this code
x <- mtcars[-1]
x <- transform(x,
    cyl = factor(cyl, ordered=TRUE),
    vs = factor(vs),
    gear = factor(gear)
)
y <- mtcars$mpg
cv <- resample("crossvalidation", y)
data <- pre_split(x, y, cv[[1]]) %>%
    pre_factor_to_logical(base = c(cyl="4", vs="0"),
                          drop=c(cyl=FALSE, gear=FALSE))
data$fit$x

Run the code above in your browser using DataLab