pct: Get the proportion for each level or range of a vector

View source: R/toolkits.R

pctR Documentation

Get the proportion for each level or range of a vector

Description

A function to calculate the proportion of each value range

Usage

pct(x, method = c("auto", "bin", "cont", "fct"), na.rm = TRUE, ...)

Arguments

x

An object

method

A method to calculate the percentage. Default is 'auto' which will attempt to choose the most fit method. 'bin' is only meaningful for vector that only has to values. 'fct' is meaningful for descrete variable 'cont' is used for continuous variables. This will break the variable into several ranges depended on the breaks specified in ...

na.rm

A logical value deciding whether NA should be removed

...

Additional parameters passed to cut. Only work if method = 'cont' See cut

Value

If method == 'bin': the percentage of non-reference level

If method == 'fct': the percentages of all levels

If method == 'cont': the percentages of all ranges based on specified breaks


oucru-biostats/C306 documentation built on July 16, 2024, 2:33 p.m.