Learn R Programming

mosaic (version 0.4-1)

tally: Tabulate categorical data

Description

Tabulate categorical data

Arguments

formula
a formula describing the type of table desired
data
a data frame or environment in which evaluation occurs
format
a character string describing the desired format of the results. One of 'default', 'count', 'proportion', or 'percent'. In case of 'default', counts are used unless there is a condi
subset
an expression evaluating to a logical vector used to select a subset of data
quiet
a logical indicating whether messages about order in which marginal distributions are calculated should be surpressed. See addmargins.
margins
a logical indicating whether marginal distributions should be displayed.
formula
a formula
data
a data frame
format
one of default, count, proportion, or percent describing the format the tallies should be returned in.
margins
a logical indicating whether margins tallies should be added.
quiet
a logical indicating whether tallying should be done quietly (vs. verbosely)
subset
an expression defining a subset of the data frame to be tallied.

Examples

Run this code
tally( ~ substance, HELPrct)
tally( ~ substance & sex , HELPrct)
tally( sex ~ substance, HELPrct)   # equivalent to tally( ~ sex | substance, ... )
tally( ~ substance | sex , HELPrct)
tally( ~ substance | sex , HELPrct, format='count')
tally( ~ substance & sex , HELPrct, format='percent')

Run the code above in your browser using DataLab