helper_indicator: Create indicators from data frame

View source: R/helper_indicator.R

helper_indicatorR Documentation

Create indicators from data frame

Description

Create indicators from data frame

Usage

helper_indicator(
  df,
  vars_indicators,
  mapvalues_from,
  mapvalues_to,
  make_factor = TRUE
)

Arguments

df

a data frame

vars_indicators

a character vector of the variables from df to create indicators for

mapvalues_from

vector to pass to plyr::mapvalues() argument from

mapvalues_to

vector to pass to plyr::mapvalues() argument to

make_factor

a logical indicating whether resulting indicators should be factors. Default is TRUE.

Value

a data frame with new columns that are the indicators from vars_indicators, with the same names pasted with "_ind".

Examples

helper_indicator(df = df_adults, 
vars_indicators = c("EF1", "EF2", "EF3"), 
mapvalues_from = 1:5, 
mapvalues_to = c(0,0,0,1,1))

lindsayevanslee/whomds documentation built on Sept. 9, 2023, 10:54 p.m.