tab: One-way tabulate table

View source: R/summarize_data.R

tabR Documentation

One-way tabulate table

Description

Returned as tibble, with percentages

Usage

tab(vctr, .drop = FALSE)

Arguments

vctr

a vector to tabulate

.drop

Handling of factor levels that don't appear in the data, passed on to group_by().

For count(): if FALSE will include counts for empty groups (i.e. for levels of factors that don't exist in the data).

[Deprecated] For add_count(): deprecated since it can't actually affect the output.

Value

tibble with columns value, n, perc

Examples

vctr <- sample(LETTERS[1:5], 1000, TRUE)
tab(vctr)
# Includes NAs count
vctr <- sample(c(LETTERS[1:5], NA), 1000, TRUE)
tab(vctr)
# For factors, by default keeps levels not present in data
vctr <- factor(
  x = sample(c(LETTERS[1:5], NA), 1000, TRUE),
  levels = c(LETTERS[1:5], "Levels", "not present", "in data")
)
tab(vctr)

edalfon/efun documentation built on June 23, 2024, 4:17 a.m.