Adding all
This commit is contained in:
parent
e237ca69df
commit
0de642bd26
|
@ -0,0 +1,9 @@
|
|||
library(tidyverse)
|
||||
load("rdas/murders.rda")
|
||||
|
||||
murders %>% mutate(abb = reorder(abb, rate)) %>%
|
||||
ggplot(aes(abb, rate)) +
|
||||
geom_bar(width = 0.5, stat = "identity", color = "black") +
|
||||
coord_flip()
|
||||
|
||||
ggsave("figs/barplot.png")
|
|
@ -0,0 +1,52 @@
|
|||
state,abb,region,population,total
|
||||
Alabama,AL,South,4779736,135
|
||||
Alaska,AK,West,710231,19
|
||||
Arizona,AZ,West,6392017,232
|
||||
Arkansas,AR,South,2915918,93
|
||||
California,CA,West,37253956,1257
|
||||
Colorado,CO,West,5029196,65
|
||||
Connecticut,CT,Northeast,3574097,97
|
||||
Delaware,DE,South,897934,38
|
||||
District of Columbia,DC,South,601723,99
|
||||
Florida,FL,South,19687653,669
|
||||
Georgia,GA,South,9920000,376
|
||||
Hawaii,HI,West,1360301,7
|
||||
Idaho,ID,West,1567582,12
|
||||
Illinois,IL,North Central,12830632,364
|
||||
Indiana,IN,North Central,6483802,142
|
||||
Iowa,IA,North Central,3046355,21
|
||||
Kansas,KS,North Central,2853118,63
|
||||
Kentucky,KY,South,4339367,116
|
||||
Louisiana,LA,South,4533372,351
|
||||
Maine,ME,Northeast,1328361,11
|
||||
Maryland,MD,South,5773552,293
|
||||
Massachusetts,MA,Northeast,6547629,118
|
||||
Michigan,MI,North Central,9883640,413
|
||||
Minnesota,MN,North Central,5303925,53
|
||||
Mississippi,MS,South,2967297,120
|
||||
Missouri,MO,North Central,5988927,321
|
||||
Montana,MT,West,989415,12
|
||||
Nebraska,NE,North Central,1826341,32
|
||||
Nevada,NV,West,2700551,84
|
||||
New Hampshire,NH,Northeast,1316470,5
|
||||
New Jersey,NJ,Northeast,8791894,246
|
||||
New Mexico,NM,West,2059179,67
|
||||
New York,NY,Northeast,19378102,517
|
||||
North Carolina,NC,South,9535483,286
|
||||
North Dakota,ND,North Central,672591,4
|
||||
Ohio,OH,North Central,11536504,310
|
||||
Oklahoma,OK,South,3751351,111
|
||||
Oregon,OR,West,3831074,36
|
||||
Pennsylvania,PA,Northeast,12702379,457
|
||||
Rhode Island,RI,Northeast,1052567,16
|
||||
South Carolina,SC,South,4625364,207
|
||||
South Dakota,SD,North Central,814180,8
|
||||
Tennessee,TN,South,6346105,219
|
||||
Texas,TX,South,25145561,805
|
||||
Utah,UT,West,2763885,22
|
||||
Vermont,VT,Northeast,625741,2
|
||||
Virginia,VA,South,8001024,250
|
||||
Washington,WA,West,6724540,93
|
||||
West Virginia,WV,South,1852994,27
|
||||
Wisconsin,WI,North Central,5686986,97
|
||||
Wyoming,WY,West,563626,5
|
|
|
@ -0,0 +1,3 @@
|
|||
url <- "https://raw.githubusercontent.com/rafalab/dslabs/master/inst/extdata/murders.csv"
|
||||
destination_file <- "data/murders.csv"
|
||||
download.file(url, destination_file)
|
|
@ -0,0 +1,13 @@
|
|||
Version: 1.0
|
||||
|
||||
RestoreWorkspace: Default
|
||||
SaveWorkspace: Default
|
||||
AlwaysSaveHistory: Default
|
||||
|
||||
EnableCodeIndexing: Yes
|
||||
UseSpacesForTab: Yes
|
||||
NumSpacesForTab: 2
|
||||
Encoding: UTF-8
|
||||
|
||||
RnwWeave: Sweave
|
||||
LaTeX: pdfLaTeX
|
|
@ -0,0 +1,2 @@
|
|||
test
|
||||
adding a line
|
Binary file not shown.
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
title: "Report on Gun Murders"
|
||||
author: "Rafael Irizarry"
|
||||
date: "`r format(Sys.Date())`"
|
||||
output: github_document
|
||||
---
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
knitr::opts_chunk$set(echo = TRUE)
|
||||
```
|
||||
|
||||
## Introduction
|
||||
|
||||
This is a report on 2010 gun murder rates obtained from FBI reports. The original data was obtained from [this Wikipedia page](https://en.wikipedia.org/wiki/Murder_in_the_United_States_by_state).
|
||||
|
||||
We are going to use the following library:
|
||||
|
||||
```{r loading-libs, message=FALSE}
|
||||
library(tidyverse)
|
||||
```
|
||||
|
||||
and load the data we already wrangled:
|
||||
|
||||
```{r}
|
||||
load("rdas/murders.rda")
|
||||
```
|
||||
|
||||
## Murder rate by state
|
||||
|
||||
We note the large state to state variability by generating a barplot showing the murder rate by state:
|
||||
|
||||
```{r murder-rate-by-state, echo=FALSE}
|
||||
murders %>% mutate(abb = reorder(abb, rate)) %>%
|
||||
ggplot(aes(abb, rate)) +
|
||||
geom_bar(width = 0.5, stat = "identity", color = "black") +
|
||||
coord_flip()
|
||||
```
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
Report on Gun Murders
|
||||
================
|
||||
Rafael Irizarry
|
||||
2018-04-16
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
This is a report on 2010 gun murder rates obtained from FBI reports. The original data was obtained from [this Wikipedia page](https://en.wikipedia.org/wiki/Murder_in_the_United_States_by_state).
|
||||
|
||||
We are going to use the following library:
|
||||
|
||||
``` r
|
||||
library(tidyverse)
|
||||
```
|
||||
|
||||
and load the data we already wrangled:
|
||||
|
||||
``` r
|
||||
load("rdas/murders.rda")
|
||||
```
|
||||
|
||||
Murder rate by state
|
||||
--------------------
|
||||
|
||||
We note the large state to state variability by generating a barplot showing the murder rate by state:
|
||||
|
||||
![](report_files/figure-markdown_github/murder-rate-by-state-1.png)
|
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
|
@ -0,0 +1,5 @@
|
|||
library(tidyverse)
|
||||
murders <- read_csv("data/murders.csv")
|
||||
murders <-murders %>% mutate(region = factor(region),
|
||||
rate = total / population * 10^5)
|
||||
save(murders, file = "rdas/murders.rda")
|
Loading…
Reference in New Issue