Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

proportions

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

Formula Interface to the Grammar of Graphics

v0.10.1
MIT + file LICENSE
Authors
Daniel Kaplan [aut], Randall Pruim [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.