Homework 2

library(knitr)
library(readr)
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.4
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching packages ──────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.0.0     ✔ purrr   0.2.5
## ✔ tibble  1.4.2     ✔ stringr 1.3.1
## ✔ tidyr   0.8.1     ✔ forcats 0.3.0
## Warning: package 'ggplot2' was built under R version 3.4.4
## Warning: package 'tidyr' was built under R version 3.4.4
## Warning: package 'purrr' was built under R version 3.4.4
## Warning: package 'stringr' was built under R version 3.4.4
## ── Conflicts ─────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(dplyrAssist)
library(ggformula)
## Warning: package 'ggformula' was built under R version 3.4.4
## Loading required package: ggstance
## Warning: package 'ggstance' was built under R version 3.4.4
## 
## Attaching package: 'ggstance'
## The following objects are masked from 'package:ggplot2':
## 
##     geom_errorbarh, GeomErrorbarh
## 
## New to ggformula?  Try the tutorials: 
##  learnr::run_tutorial("introduction", package = "ggformula")
##  learnr::run_tutorial("refining", package = "ggformula")
library("ggplot2", lib.loc="~/var/folders/j8/hf3z0n652vv1qlzkjzbxgj940000gn/T//RtmpMzETU8/downloaded_packages")
cancer_data <- read_csv("~meredithpowers/Desktop/hw2.csv", col_names = TRUE)
## Parsed with column specification:
## cols(
##   .default = col_integer(),
##   Geo_NAME = col_character(),
##   Geo_QNAME = col_character(),
##   Geo_COUNTY = col_character(),
##   SE_T008_001 = col_double(),
##   SE_T008_002 = col_double(),
##   SE_T008_003 = col_double(),
##   SE_T008_004 = col_double(),
##   SE_T008_005 = col_double(),
##   SE_T008_006 = col_double(),
##   SE_T008_007 = col_double(),
##   SE_T008_008 = col_double(),
##   SE_T008_009 = col_double(),
##   SE_T008_010 = col_double(),
##   SE_T008_011 = col_double(),
##   SE_T008_012 = col_double()
## )
## See spec(...) for full column specifications.
cancer_data %>% 
select(Geo_NAME, SE_NV026_004, SE_NV026_005, SE_NV026_006, SE_NV026_007, SE_NV026_008, SE_NV026_009, SE_NV026_010, SE_NV026_011, SE_NV026_012) %>% rename(County = Geo_NAME , Cancer_Deaths_18_to_44_Yearolds = SE_NV026_004 , Cancer_Deaths_18_to_44_Female = SE_NV026_005 , Cancer_Deaths_18_to_44_Male = SE_NV026_006 , Cancer_Deaths_45_to_64_Yearolds = SE_NV026_007 , Cancer_Deaths_45_to_64_Female = SE_NV026_008 , Cancer_Deaths_45_to_64_Male =    SE_NV026_009 , Cancer_Deaths_65_Plus =  SE_NV026_010 , Cancer_Deaths_65_Plus_Female =   SE_NV026_011, Cancer_Deaths_65_Plus_Male =  SE_NV026_012 ) -> cancer_data
head(cancer_data)
nystate_data <- filter(cancer_data, County %in% c('Fulton County','Kings County','New York County','Oswego County','Queens County'))
## Warning: package 'bindrcpp' was built under R version 3.4.4
nystate_graph <- ggplot(data = nystate_data, aes(x=County, y=Cancer_Deaths_18_to_44_Yearolds)) + geom_bar(stat='identity',fill='red',color='black') + ggtitle('Total Cancer Deaths for 18 to 44 Yearolds - Selected NY State Counties')
nystate_graph