# NOT RUN {
# Compare sex distribution by group
(freqtable1 <- tabfreq(Sex ~ Group, data = tabdata))
# Same as previous, but specifying input vectors rather than formula
(freqtable2 <- tabfreq(x = tabdata$Group, y = tabdata$Sex))
# Same as previous, but showing male row only and percent (SE) rather than n
# (percent)
(freqtable3 <- tabfreq(Sex ~ Group, data = tabdata,
cell = "col.percent", parenth = "se",
compress.binary = TRUE))
# Create single table comparing sex and race in control vs. treatment group.
# Drop missing observations first.
tabdata2 <- subset(tabdata, ! is.na(Sex) & ! is.na(Race))
(freqtable4 <- rbind(tabfreq(Sex ~ Group, data = tabdata2),
tabfreq(Race ~ Group, data = tabdata2)))
# Same as previous, but using tabmulti for convenience
#(freqtable5 <- tabmulti(data = d, xvarname = "Group",
# yvarnames = c("Sex", "Race")))
# }
Run the code above in your browser using DataLab