proportions: Compute groupwise proportions and percents

percs_by_groupR Documentation

Compute groupwise proportions and percents

Description

Transform a vector of counts and a vector of groups into a vector of proportions or percentages within groups.

Usage

percs_by_group(x, group)

props_by_group(x, group)

Arguments

x

A vector of counts

group

A vector to determine groups.

Examples


x <- c(20, 30, 30, 70)
g1 <- c("A", "A", "B", "B")
g2 <- c("A", "B", "A", "B")
props_by_group(x, g1)
percs_by_group(x, g1)
props_by_group(x, g2)

ggformula documentation built on Nov. 9, 2023, 5:08 p.m.