prop_table: Create a standard relative frequency table.

View source: R/tables.R

prop_tableR Documentation

Create a standard relative frequency table.

Description

Create a simple relative frequency table with percentages, optionally while using sampling weights.

Usage

prop_table(vec, weights = NULL, na.rm = FALSE, round_perc = 1)

Arguments

vec

A vector.

weights

A numeric vector of non-negative weights.

na.rm

Set to FALSE to suppress checking for NAs. If TRUE, NAs are removed from x as well as from weights prior to variance estimation.

round_perc

With how many decimals should the percentages be given?

Value

Returns a data.frame with 1 row.

Examples

# without weights
prop_table(mtcars$cyl)

# with weights
prop_table(mtcars$cyl, weights = rep(c(0.5, 1), 16))


beckerbenj/eatAnalysis documentation built on July 7, 2023, 5:51 p.m.