Learn R Programming

mosaic (version 0.9-0)

prop: Compute proportions, percents, or counts for a single level

Description

Compute proportions, percents, or counts for a single level

Usage

prop(x, data = parent.frame(), ..., level = NULL, long.names = TRUE,
  sep = ".", format = "proportion")

count(x, data = parent.frame(), ..., format = "count")

perc(x, data = parent.frame(), ..., format = "percent")

Arguments

x
an R object, usually a formula
data
a data frame in which x is to be evaluated
...
arguments passed through to tally
level
the level for which counts, proportions or percents are calculated
long.names
a logical indicating whether long names should be when there is a conditioning variable
sep
a character used to separate portions of long names
format
one of proportion, percent, or count, possibly abbrevaited

Examples

Run this code
prop( ~sex, data=HELPrct)
prop( ~sex, data=HELPrct, level='male')
count( ~sex | substance, data=HELPrct)
prop( ~sex | substance, data=HELPrct)
perc( ~sex | substance, data=HELPrct)

Run the code above in your browser using DataLab