consolidate_values: Attempt to Rationalise a Factor Variable (using simple rules)

Description Usage Arguments Value Author(s)

Description

consolidate_values aims to do some of the work of the grunt work of rationalising factor levels for you. Using some very simple rules, it will attempt to turn a vector containing what appear to be gramatical variations on common patterns, into one with these rationalised to a smaller set of values.

Usage

1
2
consolidate_values(x, case = "lower",
  na_regex = "no info*|don't know|<na>|#na|n/a|^[[:space:]]*$")

Arguments

x

The factor variable which you'd like to consolidate the levels of

case

The case which the levels of x will be converted to. Can be one of "lower", "upper".

na_regex

A regular expression which will be used to set values of x to NA.

Value

factor, hopefully with consolidated levels

Author(s)

Brendan Rocks rocks.brendan@gmail.com


brendan-R/brocks documentation built on May 13, 2019, 5:07 a.m.