Learn R Programming

radiant.data (version 1.4.5)

prop: Calculate proportion

Description

Calculate proportion

Usage

prop(x, na.rm = TRUE)

Value

Proportion of first level for a factor and of the maximum value for numeric

Arguments

x

Input variable

na.rm

If TRUE missing values are removed before calculation

Examples

Run this code
prop(c(rep(1L, 10), rep(0L, 10)))
prop(c(rep(4, 10), rep(2, 10)))
prop(rep(0, 10))
prop(factor(c(rep("a", 20), rep("b", 10))))

Run the code above in your browser using DataLab