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"]]), ]
crosstable(df, Race, party)
# Tea-Tasting Experiment data
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")
crosstable(data, poured, guess, row=TRUE, column=TRUE) # fisher=TRUE
Run the code above in your browser using DataLab