calc_perc: Compute a percentage

View source: R/calc_perc.r

calc_percR Documentation

Compute a percentage

Description

Compute the percentage based on one or multiple variables.

Usage

calc_perc(df, grp_var, main_var = NULL)

Arguments

df

A single data.frame

grp_var

The grouping variable(s) based on which the percentages will be computed

main_var

An optional variable, when provided, will be utilized to compute the percentage for each of its own levels

Value

A data.frame summarizing the counts and percentages within groups. The output is arranged in descending order of counts within each group.

Examples


#without main_var
calc_perc(mtcars,grp_var = c(cyl,vs))

#main_var within grp_var
calc_perc(mtcars,grp_var = c(cyl,vs),main_var = vs)

#main_var not within grp_var
calc_perc(mtcars,grp_var = c(cyl),main_var = vs)

vbfelix/relper documentation built on May 10, 2024, 10:50 p.m.