Learn R Programming

mosaic (version 0.10.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(), useNA = "no", ..., level = NULL,
  long.names = TRUE, sep = ".", format = "proportion", quiet = TRUE)

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
useNA
an indication of how NA's should be handled. By default, they are ignored.
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
quiet
a logical indicating whether messages regarding the target level should be supressed.
...
arguments passed through to tally

Examples

Run this code
if (require(mosaicData)) {
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