4 Tabular Data
Previously, we learned how to work with bivariate data, working with each individual data point. Here, we view two-dimensional data where each dimension has been summarized into several discrete categories. We refer to this summary as a table and the data as tabular data.
Learning Objectives
- Learn how to represent and analyze tabular data.
- Learn about Simpson’s Paradox, one of the dangers of not controlling for confounding variables.
- Learn about sensitivity and specificity in tests, particularly medical diagnoses.
Useful Functions
Use
matrix()
to create a matrix or two-way table.- Use
barplot()
to make a bar plot. Use
mosaicplot()
to make a mosaic plot.- Use
margin.table()
to calculate the marginal distributions of a table. - Use
prop.table()
to calculate the joint and conditional probabilities of a table. Use
chisq.test()
to perform a chi-squared test.