Learn R Programming

mosaic (version 0.9-0)

tally: Tabulate categorical data

Description

Tabulate categorical data

Usage

tally(x, ...)

## S3 method for class 'tbl': tally(x, wt, sort = FALSE, ...)

## S3 method for class 'default': tally(x, data = parent.frame(), format = c("default", "count", "proportion", "percent"), margins = FALSE, quiet = TRUE, subset, useNA = "ifany", ...)

Arguments

x
an object
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 condition, in
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.
useNA
as in table, but the default here is "ifany".
...
additional arguments passed to table
wt
for weighted tallying, see tally in dplyr
sort
a logical, see tally in dplyr

Examples

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

Run the code above in your browser using DataLab