Description Usage Arguments Value Methods (by class) Author(s) See Also Examples
Generates a table of frequencies or relative frequencies or relative percentages
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | tab(x, ...)
## S3 method for class 'table'
tab(x, ...)
## S3 method for class 'matrix'
tab(x, ...)
## S3 method for class 'array'
tab(x, ...)
## S3 method for class 'formula'
tab(fmla, data = sys.frame(sys.parent()), ...)
## S3 method for class 'data.frame'
tab(dd, fmla, total.margins = TRUE, useNA = "ifany",
pct = NULL, pr = NULL, test = FALSE, weights = NULL, na.rm = NULL,
all.label = "All")
## Default S3 method:
tab(..., total.margins = TRUE, pct = NULL, pr = NULL,
useNA = "ifany", test = FALSE, weights = NULL, na.rm = NULL,
all.label = "All")
|
fmla |
a formula whose right-hand side names the variables to be used for tabulation. The optional left-hand side specifies a variable to be used for weights. |
data |
a data frame in which formula are interpreted |
total.margins |
if FALSE, generate table without margins |
useNA |
whether to include NA levels. The default is "ifany". Can also be set to "no" or "always". |
pct |
margins to be scaled to sum to 100. This is the vector of margin indices on which percentages are conditioned. For example, with the call |
pr |
margins to be scaled to sum to 1. This is the vector of margin indices on which percentages are conditioned. |
weights |
(not working temporarily) instead of generating a frequency table, generate a table with the sum of the weights |
... |
as with |
keep |
names of margins to keep with 'Tab', default = "All". To drop all margins, use default = "". |
An object of class 'table' of dimension equal to the number of variables, with optional margins showing totals. Elements of the matrix can be frequencies, relative frequencies, percentages or sums of weights.
table
: method class table
matrix
: method for matrices
array
: method for arrays
formula
: method for formulas
data.frame
: method for data frames
default
: default method
Georges Monette
tab_
(synonym: Tab) to drop "Total" margins.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | titanic <- as.data.frame(Titanic)
head(titanic)
tab(titanic, Freq ~ Sex + Age)
tab(titanic, Freq ~ Sex + Survived + Age)
round(tab(titanic, Freq ~ Sex + Survived + Age,
pct = c(1,3)),2)
round(Tab(titanic, Freq ~ Sex + Survived + Age,
pct = c(1,3)),2)
round(Tab(titanic, Freq ~ Sex + Survived + Age,
pct = c(1,3), keep = ""),2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.