library(tidyverse)
library(mosaic)
library(rio)
library(car)
<- import('https://raw.githubusercontent.com/byuistats/Math221D_Cannon/master/Data/chiropractic_data.csv') chiropractic
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
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.
<- table() chiro_tbl
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:
<- table() chiro_tbl2
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: