NoYes: Convert a logical vector to a two-level factor

Description Usage Arguments Value Examples

View source: R/factor_functions.R

Description

Converts a logical vector to a factor conatining two levels. This is useful in statistical models such as logistic regression, both for the dependent variable and the explanatory variables.

Usage

1
NoYes(bool, levels = c("No", "Yes"))

Arguments

bool

A logical vector, or a vector that can be coerced to logical.

levels

Two factor levels for FALSE and TRUE values, respectively.

Value

A factor with two levels.

Examples

1
2
table(NoYes(LETTERS %in% c('A','E','I','O','U')))
table(NoYes(runif(100) > 0.5, c('Tails', 'Heads')))

stevetnz/stevesRfunctions documentation built on May 28, 2019, 8:21 a.m.