Learn R Programming

emil (version 2.2.10)

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

data

Pre-processed data set, as produced by pre_split.

feature

Character vector with names of features to convert. Defaults to all factors in the data set.

base

Sent to factor_to_logical. To specify different bases for different columns supply a vector or list with named elements.

drop

Sent to factor_to_logical. To specify different bases for different columns supply a vector or list with named elements.

Examples

Run this code
# NOT RUN {
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