sex <- factor(rbinom(1:1000, 1, 0.5), labels=c("male" , "female"))
age <- factor(rbinom(1:1000, 2, 0.4), labels=c("young", "middle", "old"))
weight <- factor(rbinom(1:1000, 2, 0.6), labels=c("light", "middle", "heavy"))
cross.table1 <- crossTable(sex, age)
summary(cross.table1)
cross.table2 <- crossTable(sex, age, weight)
summary(cross.table2)
summary(cross.table2, latex = TRUE)
Run the code above in your browser using DataLab