binary_patterns_var: Combines (usually multiple) binary vectors into a convenient...

Description Usage Arguments Value Examples

View source: R/binary_patterns_var.R

Description

This is useful when you have a collection of yes/no variables representing multiple choices in which more than one option can be selected.

Usage

1
2
3
4
5
6
7
binary_patterns_var(
  data,
  strip_prefix = "",
  mid_sep = ", ",
  last_sep = " & ",
  none_label = "(None)"
)

Arguments

data

Data frame or tibble containing the binary vectors

strip_prefix

A common prefix to remove from the start of the variable names

mid_sep

Character to separate names, by default a comma

last_sep

The last separator to use, by default an ampersand

none_label

How to represent the empty combination

Value

A character vector representing combinations of inputs

Examples

1
2
3
4
5
test1 <- expand.grid(myvar_1 = c(0,1), 
                     myvar_2 = c(0,1),
                     myvar_3 = c(0,1))
test1$pat <- binary_patterns_var(test1, "myvar_")
test1

InductiveStep/handbag documentation built on Aug. 2, 2020, 7:28 a.m.