tab_prepare {tabxplor}R Documentation

Prepare data for tab_plain.

Description

Prepare data for tab_plain.

Usage

tab_prepare(
  data,
  ...,
  na_drop_all,
  cleannames = NULL,
  rare_to_other = FALSE,
  n_min = 30,
  other_level = "Others"
)

Arguments

data

A dataframe.

...

Variables then to be passed in tab_plain.

na_drop_all

<tidy-select> Removes all observation with a NA in any of the chosen variables.

cleannames

Set to TRUE to clean levels names, by removing prefix numbers like "1-", and text in parentheses.

rare_to_other

When set to TRUE, levels with less count than n_min will be merged into an "Other" level.

n_min

The count under which a level is aggregated in the "Other" level.

other_level

The name of the "Other" level, as a character vector of length one.

Value

A modified data.frame.

Examples

data <- dplyr::starwars %>%
tab_prepare(sex, hair_color, gender, rare_to_other = TRUE,
            n_min = 5, na_drop_all = sex)
data


[Package tabxplor version 1.1.3 Index]