clean_col_content: Clean column content

Description Usage Arguments Details Value Author(s) Examples

View source: R/clean_col_content.R

Description

It cleans column content (my relative definition of 'clean'). Specifically, it separates with underscore (e.g., "pikaPika" to "pika_Pika"), replaces blank spaces with underscore, replaces multiple symbols with single underscore, and removes symbols after last word. These steps are followed IN THAT ORDER. It acts in character and factor variables. It gives a warning message if it is a factor. It does nothing to vectors other than character and factors.

Usage

1
clean_col_content(x, warning_msg = TRUE)

Arguments

x

A factor of character vector.

warning_msg

Logical. Turn on and off warning message for factors

Details

It is basically the same as clean_colnames. The idea is that they do slightly different things in the future. The difference is that clean_colnames gives a warning for repeated column names while clean_col_content gives instead a warning if the column is a factor.

Value

A cleaner character of factor (same type as x).

Author(s)

Guillermo Basulto-Elias

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
clean_col_content(c("bart Simpson", "LisaSimpson",
                    "maggie..simpson!",
                    "MARGE-Simpson", "Homer Simpson :-)"))

## Get warning for factors.
## Not run: 
clean_col_content(
   factor(c("bart  Simpson", "LisaSimpson",
            "maggie..simpson!", "MARGE-Simpson",
            "bart  Simpson", "Homer Simpson :-)")))

## End(Not run)

gbasulto/rmiscfun documentation built on July 25, 2019, 8:56 p.m.