knitr::opts_chunk$set(echo = TRUE)
This is my R Markdown document which I created to be exported to an HTML web page. Thanks for all your help Professor! I had a lot of fun with it, once it actually worked :) I have some additional questions… I will explain below.
Separating out the categorical responses to mask-wearing habits, this is exactly what I wanted to do, yes!
library(readxl)
mask_use_by_county_TIDY <- read_xlsx("~/Downloads/mask_use_by_county_TIDY.xlsx")
library(ggplot2)
mask_use_by_county_TIDY$CATEGORY2 <- factor(mask_use_by_county_TIDY$CATEGORY,
levels = c("NEVER",
"RARELY",
"FREQUENTLY",
"ALWAYS",
"SOMETIMES"))
names(mask_use_by_county_TIDY)
## [1] "COUNTY" "CATEGORY" "VALUE" "CATEGORY2"
table(mask_use_by_county_TIDY$CATEGORY2)
##
## NEVER RARELY FREQUENTLY ALWAYS SOMETIMES
## 83 83 83 83 83
Here, I used the formulas from above to try to separate out some counties.
mask_use_by_county_TIDY$COUNTY2 <- factor(mask_use_by_county_TIDY$COUNTY,
levels = c("26161",
"26163",
"26125",
"26093"))
summary(mask_use_by_county_TIDY$COUNTY2)
## 26161 26163 26125 26093 NA's
## 5 5 5 5 395
p2 <- ggplot(mask_use_by_county_TIDY,
aes(x = CATEGORY2,
color = CATEGORY2,
y = VALUE)) +
geom_jitter()
p2
## Isolated Counties Plots
Here,I attempted to use my additional factoring above to show difference in mask-wearing habits in Washtenaw, Livingston, Wayne, and Oakland counties, however I am kind of stuck. I kind of want to introduce a third varible? I want to be able to show CATEGORY2XVALUE with County Labels (4 counties). The can’t tell if the graph I produced below really tells us anything value wise, ie. does the position of the dot tell us anything? it’s unclear to me.
p3 <- ggplot(mask_use_by_county_TIDY,
aes(x = CATEGORY2,
color = CATEGORY2,
y = COUNTY2)) +
geom_jitter()
p3
Thanks for introducing me to this kind of plot! This is really cool! I still plan to work on axis labels & headers before I turn this in too, and obviously I am keeping all my “echo=TRUE” for now so you can see my work. If you don’t have a chance to get back to me before Friday, I am fine with waiting to ask these questions in class! Thanks again!! - Erika
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
ggplotly(p3)
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.