Learn R Programming

sjmisc (version 2.7.7)

tidy_values: Tidy values of character vectors.

Description

This function "cleans" values of a character vector or levels of a factor by removing space and punctuation characters.

Usage

tidy_values(x, ...)

Arguments

x

A vector or data frame.

...

Optional, unquoted names of variables that should be selected for further processing. Required, if x is a data frame (and no vector) and only selected variables from x should be processed. You may also use functions like : or tidyselect's select_helpers. See 'Examples' or package-vignette.

Value

x, with "cleaned" values or levels.

Examples

Run this code
# NOT RUN {
f1 <- sprintf("Char %s", sample(LETTERS[1:5], size = 10, replace = TRUE))
f2 <- as.factor(sprintf("F / %s", sample(letters[1:5], size = 10, replace = TRUE)))
f3 <- sample(1:5, size = 10, replace = TRUE)

x <- data.frame(f1, f2, f3, stringsAsFactors = FALSE)

tidy_values(f1)
tidy_values(f2)
tidy_values(x)

# }

Run the code above in your browser using DataLab