R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

Code borrorwed from storybench

# Packages ----------------------------------------------------------------
library(ggplot2)

murders_separate <- read.csv(file="murders_separate.csv")

Including Plots

You can also embed plots, for example:

ggplot(murders_separate, aes(x=year, y=murders, group=city)) +
  geom_line() +
  scale_x_continuous(breaks=c(2014,2015))

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

ggplot(murders_separate, aes(x=year, y=murders, group=city, color=city)) +
  geom_line()+
  scale_x_continuous(breaks=c(2014,2015))

ggplot(subset(murders_separate, murders > 150), aes(x=year, y=murders, group=city, color=city)) +geom_line()+
  scale_x_continuous(breaks=c(2014,2015))

ggplot(subset(murders_separate, murders > 200), aes(x=year, y=murders, group=city, color=city)) +geom_line()+
 facet_grid(city ~ .)+
 scale_x_continuous(breaks=c(2014,2015))

ggplot(subset(murders_separate, murders > 200), aes(x=year, y=murders, group=city, color=city)) +
  geom_line()+
  facet_wrap(~ city)+
  labs(title = "Murder change between 2014 and 2015")+
  scale_x_continuous(breaks=c(2014,2015))+
  theme(axis.ticks = element_blank(), axis.text.x = element_blank(), legend.position = "none")