Description Usage Arguments Value See Also Examples
Crosstable
produces all possible two-way and three-way tabulations of variables.
1 2 3 4 5 6 7 |
digits |
number of digits after the decimal point. |
chisq |
if |
fisher |
if |
mcnemar |
if |
latex |
if the output is to be printed in latex format. |
alt |
the alternative hypothesis and must be one of "two.sided", "greater" or "less". Only used in the 2 by 2 case. |
deparse.level |
an integer controlling the construction of labels in the case of non-matrix-like arguments. If 0, middle 2 rownames, if 1, 3 rownames, if 2, 4 rownames (default). |
... |
the variables for the cross tabulation. |
A cross-tabulated object.
xtabs
, Frequency
,
table
, prop.table
Other Crosstables: summary.Crosstable
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | with(titanic, Crosstable( SEX, AGE, SURVIVED))
#' # Agresti (2002), table 3.10, p. 106
# 1992 General Social Survey--Race and Party affiliation
gss <- data.frame(
expand.grid(Race=c("black", "white"),
party=c("dem", "indep", "rep")),
count=c(103,341,15,105,11,405))
df <- gss[rep(1:nrow(gss), gss[["count"]]), ]
with(df, Crosstable(Race, party))
# Agresti (1990, p. 61f; 2002, p. 91) Fisher's Tea Drinker
tea <- data.frame(
expand.grid(poured=c("Yes", "No"),
guess=c("Yes", "No")),
count=c(3,1,1,3))
# nicer way of recreating long tables
data = Untable(tea, freq="count")
with(data, Crosstable(poured, guess, fisher=TRUE, alt="greater")) # fisher=TRUE
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.