Practice: Summarizing Categorical Data

Introduction

Reasons why patients visit a chiropractor vary and may depend on where you live.

Use the chiropractic dataset to practice summarizing categorical data.

Load the Libraries and Data

library(tidyverse)
library(mosaic)
library(rio)
library(car)

chiropractic <- import('https://raw.githubusercontent.com/byuistats/Math221D_Cannon/master/Data/chiropractic_data.csv')

Why Visit?

QUESTION: List all the levels for motivation in the data:

unique()
Error in unique.default(): argument "x" is missing, with no default

Create a sorted bar chart for reasons why people see a chiropractor:

QUESTION: What is the most common motivation for visiting a chiropractor?
ANSWER:

Regional Differences?

Create and name a contingency table that counts the motivation by region.

chiro_tbl <- table()
Error in table(): nothing to tabulate
prop.table()
Error in prop.table(): argument "x" is missing, with no default

HINT: Proportions should sum to 1 for each region. Which margin you use will depend on how you defined your table above.

QUESTION: What percent of Australians visit a chiropractor for Wellness?
ANSWER:

QUESTION: What percent of Europeans visit a chiropractor for Wellness?
ANSWER:

Visualize

Use the chiro_tbl created above to create a grouped bar chart:

Swap the row and column table and recreate the graph above with the opposite grouping:

chiro_tbl2 <- table()
Error in table(): nothing to tabulate
barplot()
Error in barplot.default(): argument "height" is missing, with no default

QUESTION: In your opinion, which visualization tells a more compelling story? Why?
ANSWER: