10. Categorical Association: Practical 10
Introduction to Cross Tables and Categorical Association
Objectives
Understand that cross tables can be used to
- describe the relationship between two categorical variables
Learn how to do the following in R
- create a cross table for two categorical variables
- plot two categorical variables
Instruction
- Read through the text below
- Execute code-examples and compare your results with what is explained in the text
- Make the exercises and compare your answers with those in the examples
- Time: 30 minutes
Introduction
In this practical, we are going to focus on categorical variables. For example sex, education level or handedness. In practical 1 we used the function table()
to count the number of occurrences in each category, thus to make frequency tables and describe the distribution of a single categorical variable. In practical 3 we used these frequency tables for probability calculations (joint and conditional probabilities). Here, we are going to use frequency tables again, but this time to test hypotheses about categorical variables.
The data
The data for this practical comes from a survey conducted among people in England about their water use, willingness to install water-saving fitters and quality of life. In this practical you will work with a small subset of the available data from those surveys. More information can be found at http://reshare.ukdataservice.ac.uk/852336/.
You can load the data with the following command:
source('http://horizon.science.uva.nl/public/VVA/waterdata.R')