binary2factor: Convert binary data to factors based on column name

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Convert binary data to factors based on column name

Usage

1

Arguments

.data

(data.frame) A data frame or data frame extension (e.g. a tibble)

...

Name-value pairs. The names of columns to be transformed

Value

(data.frame) An object of the same type as .data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
df <- data.frame(
  a = c(1, 0, NA, 1, 0),
  b = c("y", "n", NA, "Y", "n"),
  c = c("yes", "no", NA, "Yes", "No"),
  d = c(TRUE, FALSE, NA, TRUE, FALSE),
  e = c(1, 2, 3, 4, 5)
)
binary2factor(df, a, b:d)
df %>%
  binary2factor(-e)

epocakir documentation built on June 9, 2021, 9:07 a.m.