crosstable(titanic, SEX, AGE)
titanic %>% tab(SEX, AGE, SURVIVED)
# Agresti (2002), table 3.11, p. 106
# 1992 General Social Survey- Sex and Party affiliation
gss <- data.frame(
expand.grid(sex=c("female", "male"),
party=c("dem", "indep", "rep")),
count=c(279,165,73,47,225,191))
#Get it expanded
df <- gss[rep(1:nrow(gss), gss[["count"]]), ]
df %>% tab(sex, party)
gender = rep(c("female","male"),c(1835,2691))
admitted = rep(c("yes","no","yes","no"),c(557,1278,1198,1493))
dept = rep(c("A","B","C","D","E","F","A","B","C","D","E","F"),
c(89,17,202,131,94,24,19,8,391,244,299,317))
dept2 = rep(c("A","B","C","D","E","F","A","B","C","D","E","F"),
c(512,353,120,138,53,22,313,207,205,279,138,351))
department = c(dept,dept2)
ucb = data.frame(gender,admitted,department)
ucb %>% tab(admitted, gender)
mytab <- tab(ucb, admitted, gender)
# Output in latex:
summary(mytab, latex = TRUE)
Run the code above in your browser using DataLab