
tally(x, ...)## S3 method for class 'tbl':
tally(x, wt, sort = FALSE, ..., envir = parent.frame())
## S3 method for class 'default':
tally(x, data = parent.frame(), format = c("count",
"proportion", "percent", "data.frame", "sparse", "default"),
margins = FALSE, quiet = TRUE, subset, useNA = "ifany", ...)
table
tally
in tally
in data=parent.frame()
. This makes it convenient to
use this function interactively by treating the working envionment as if it were
a data frame. But this may no'default'
, 'count'
, 'proportion'
, 'percent'
,
'data.frame'
, 'sparse'
, or 'default'
addmargins
.data
table
, but the default here is "ifany"
.tally
function. If x
inherits
from class "tbl"
, then tally
is called. This makes it
easier to have the two package coexist.if (require(mosaicData)) {
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')
# force NAs to show up
tally( ~ sex, data=HELPrct, useNA="always")
# show NAs if any are there
tally( ~ link, data=HELPrct)
# ignfore the NAs
tally( ~ link, data=HELPrct, useNA="no")
}
Run the code above in your browser using DataLab