tab_prepare: Prepare data for 'tab_plain'.

tab_prepareR Documentation

Prepare data for tab_plain.

Description

Prepare data for tab_plain.

Usage

tab_prepare(
  data,
  ...,
  na_drop_all,
  cleannames = NULL,
  other_if_less_than = 0,
  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.

other_if_less_than

When set to a positive integer, levels with less count than it will be merged into an "Others" 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, other_if_less_than = 5,
            na_drop_all = sex)
data


BriceNocenti/tablr documentation built on April 12, 2025, 12:56 a.m.