3. n Introduction
n Reading Data into R (1)
n Reading Data into R (2)
n Descriptive statistics
Previously in this group
Group Website: http://rpubs.com/kaz_yos/useR_at_HSPH
5. Ingredients
n n
n table(), summary()
n xtabs(), ftable()
n prop.table()
n margin.table()
n CrossTable()
Statistics
Summary statistics for
categorical data
Programming
Creating categorical var.
30. Create flat tables
Good for > 3 dimentional
ftable(..., exclude = c(NA, NaN),
row.vars = NULL, col.vars = NULL)
31. Your turn
n table3 <- xtabs(~ Treatment +Improved +Sex,
Arthritis)
n Do ftable(table3)
adopted from Hadley Wickham
32. Your turn
n table2d <- xtabs(~ Treatment +Improved,
Arthritis)
n
n
n
prop.table(table2d)
prop.table(table2d, 1)
prop.table(table2d, 2)
adopted from Hadley Wickham
33. CrossTable
CrossTable(x, y, digits=3, max.width =
5, expected=FALSE, prop.r=TRUE,
prop.c=TRUE, prop.t=TRUE,
prop.chisq=TRUE, chisq = FALSE,
fisher=FALSE, mcnemar=FALSE,
resid=FALSE, sresid=FALSE,
available in
gmodels package
SAS-like cross tables
34. Your turn
n table2d <- xtabs(~ Treatment +Improved,
Arthritis)
n CrossTable(table2d)
adopted from Hadley Wickham