Start a new Rmd
document by going to File-->New File-->R Markdown--OK
. Save this document under the name yourname_hw5.Rmd
. Delete the template Rmarkdown text and chunks (everything starting with ##R Markdown).
Make a new code chunk (CTRL
+Alt
+I
on Windows, Cmd
+ Option
+ I
on a Mac). In that chuck, load ggplot2
, tidyverse
, magrittr
, and classdata
libraries. Please re-install the classdata
packages to get the most updated version of the data.
Run the following code chunk to load the covid
dataset and to remove any missing observations.
data(covid)
covid<-na.omit(covid)
Start a new code chunk. Use a sequence of functions combined by pipe operators to
blue
that is equal to “Democrat” if a county voted for Hilary and “Republican” otherwise;blue
and by month
(you can do this in one step or in several steps);blue
. Choose the most appropriate plot type for comparing the proportion of cases in blue and red counties over time. Make your plot look as nice as you can.What does your plot show?
Use a series of functions combined by pipe operators to:
month.
Interpret the plot in Q6.
Knit the RMarkdown file (press the “Knit” button above) and read through the corresponding html file.
For the submission: submit your solution in an R Markdown file and (just for insurance) submit the corresponding html file with it.