R/explore.R
prop.Rd
Calculate proportion
prop(x, na.rm = TRUE)
Input variable
If TRUE missing values are removed before calculation
Proportion of first level for a factor and of the maximum value for numeric
prop(c(rep(1L, 10), rep(0L, 10))) #> [1] 0.5 prop(c(rep(4, 10), rep(2, 10))) #> [1] 0.5 prop(rep(0, 10)) #> [1] 0 prop(factor(c(rep("a", 20), rep("b", 10)))) #> [1] 0.6666667