Learn R Programming

explore (version 0.8.0)

clean_var: Clean variable

Description

Clean variable (replace NA values, set min_val and max_val)

Usage

clean_var(
  data,
  var,
  na = NA,
  min_val = NA,
  max_val = NA,
  max_cat = NA,
  rescale01 = FALSE,
  simplify_text = FALSE,
  name = NA
)

Value

Dataset

Arguments

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

Rescale into value 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)

Examples

Run this code
clean_var(iris, Sepal.Width, max_val = 3.5, name = "sepal_width")

Run the code above in your browser using DataLab