# Create a cross-tabulation demo data
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xtab <- as.table(
rbind(c(20, 5), c(16,9))
)
dimnames(xtab) <- list(
before = c("non.smoker", "smoker"),
after = c("non.smoker", "smoker")
)
xtab
# Convert into a data frame of cases
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
df <- counts_to_cases(xtab)
head(df)
Run the code above in your browser using DataLab