Description Usage Arguments Value Author(s)
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.
All strings are converted to the same case (lower, by default)
Spaces around slashes, before commas, or after common currency symbols are removed
All underscores and full stops are replaced with spaces
All continuous whitespace is converted to a single space
All trailing and leading whitespace is removed
Blank values ("") are converted to NA
Any strings which match na_regex
are converted to NA
.
1 2 | consolidate_values(x, case = "lower",
na_regex = "no info*|don't know|<na>|#na|n/a|^[[:space:]]*$")
|
x |
The |
case |
The case which the levels of |
na_regex |
A regular expression which will be used to set values of
|
factor
, hopefully with consolidated levels
Brendan Rocks rocks.brendan@gmail.com
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.