prop: Calculate a proportion or a ratio from a vector.

Description Usage Arguments Value Examples

View source: R/prop.R

Description

Calculate a proportion or a ratio from a vector.

Usage

1
2
3
prop(x, numerator, denominator, percent = TRUE, round = TRUE, digits = 1)

ratio(x, numerator, denominator, round = FALSE, digits = 1)

Arguments

x

A vector to calculate a proportion or ratio from.

numerator

A vector of elements to count in the numerator.

denominator

For lb_prop this is a vector of elements to count in the denominator in addition to those included in the numerator. For lb_ratio the values given by the numerator argument are not added.

round

A logical indicating whether to round the output.

digits

The number of decimal places to round to, passed to the round function.

percect

A logical indicating whether to present the output as a percentage rather than a proportion..

Value

prop returns the proportion of specified values, presented as a percentage or raw proportion.

ratio returns a ratio.

Examples

1
2
3
4
5
6
example <- c(T, T, T, T, T, F, F, F, NA)
prop(x = example, numerator = T, denominator = F)
prop(x = example, numerator = T, denominator = F, percent = FALSE, digits = 3)

ratio(example, T, F)
ratio(example, T, F, round = TRUE)

leebunce/leebunce documentation built on Jan. 31, 2018, 5:29 p.m.