pre_factor_to_logical: Convert factors to logical columns

Description Usage Arguments Author(s) Examples

View source: R/preprocessing.r

Description

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

Usage

1

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.

Author(s)

Christofer Bäcklin

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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

emil documentation built on Aug. 1, 2018, 1:03 a.m.