Description Usage Arguments Value Examples
This function "cleans" values of a character vector or levels of a factor by removing space and punctuation characters.
1 2 3 | tidy_values(x, ...)
clean_values(x, ...)
|
x |
A vector or data frame. |
... |
Optional, unquoted names of variables that should be selected for
further processing. Required, if |
x
, with "cleaned" values or levels.
1 2 3 4 5 6 7 8 9 | 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)
clean_values(f1)
clean_values(f2)
clean_values(x)
|
[1] "Char_B" "Char_D" "Char_B" "Char_E" "Char_E" "Char_C" "Char_E" "Char_D"
[9] "Char_D" "Char_D"
[1] F_d F_e F_c F_d F_c F_e F_d F_e F_a F_a
Levels: F_a F_c F_d F_e
# A tibble: 10 x 3
f1 f2 f3
<chr> <fct> <int>
1 Char_B F_d 1
2 Char_D F_e 4
3 Char_B F_c 3
4 Char_E F_d 4
5 Char_E F_c 5
6 Char_C F_e 4
7 Char_E F_d 1
8 Char_D F_e 1
9 Char_D F_a 4
10 Char_D F_a 4
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.