From the course: R Essential Training Part 2: Modeling Data

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating contingency tables

Creating contingency tables

From the course: R Essential Training Part 2: Modeling Data

Start my 1-month free trial

Creating contingency tables

- [Instructor] When your data consists of categories, nominal or sometimes called discrete variables, you usually want to use something different from a correlation coefficient and a contingency table or a cross tabulation is a very common way of looking at that. I want to show you how to do these in R. Let's start by loading a few packages, and then I went to load the state data, the Google search terms dataset, except this time we're not going to look at the search terms, we're going to look at the factors, and that's psych regions and region of the United States, and I'm going to pull those out. I'm also going to convert them from character variables to factors. And then I'm going to do this one other little thing. The psych regions have really long labels, friendly and conventional, temperamental and uninhibited, and that actually makes the table hard to read because they're so long. I'm going to use factor recode…

Contents