clean_var | R Documentation |
Clean variable (replace NA values, set min_val and max_val)
clean_var(
data,
var,
na = NA,
min_val = NA,
max_val = NA,
max_cat = NA,
rescale01 = FALSE,
simplify_text = FALSE,
name = NA
)
data |
A dataset |
var |
Name of variable |
na |
Value that replaces NA |
min_val |
All values < min_val are converted to min_val (var numeric or character) |
max_val |
All values > max_val are converted to max_val (var numeric or character) |
max_cat |
Maximum number of different factor levels for categorical variable (if more, .OTHER is added) |
rescale01 |
IF TRUE, value is rescaled between 0 and 1 (var must be numeric) |
simplify_text |
If TRUE, a character variable is simplified (trim, upper, ...) |
name |
New name of variable (as string) |
Dataset
library(magrittr)
iris %>% clean_var(Sepal.Width, max_val = 3.5, name = "sepal_width") %>% head()
iris %>% clean_var(Sepal.Width, rescale01 = TRUE) %>% head()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.