| percent {rapportools} | R Documentation |
Calculates percentage of cases for provided variable and
criteria specified in subset argument. Function
accepts numeric, factor and logical variables for x
parameter. If numeric and/or factor is provided, subsetting
can be achieved via subset argument. Depending on
value of na.rm argument, either valid (na.rm =
TRUE) or all cases (na.rm = FALSE) are taken into
account. By passing logical variable to x, a sum of
(TRUE) elements is calculated instead, and valid
percents are used (NA are excluded).
percent(x, subset = NULL, na.rm = TRUE, pct = FALSE, ...)
x |
a numeric variable to be summarised |
subset |
an expression that evaluates to logical
vector (defaults to |
na.rm |
should missing values be |
pct |
print percent string too? |
... |
additional arguments for |
a numeric or string depending on the value of pct
## Not run: set.seed(0) x <- sample(5, 100, replace = TRUE) percent(x > 2) ## End(Not run)