library(RCurl)
## Loading required package: bitops
library(dplyr)
##
## 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(tidyr)
##
## Attaching package: 'tidyr'
## The following object is masked from 'package:RCurl':
##
## complete
library(useful)
## Loading required package: ggplot2
URL <- getURL("https://raw.githubusercontent.com/DanielBrooks39/IS607/master/Project%202/Death%20Rate%20Data.csv")
DeathData <- read.csv(text = URL, header = TRUE)
tbl_df(DeathData)
## Source: local data frame [88 x 5]
##
## Year Ages Both.sexes Female Male
## (int) (fctr) (dbl) (dbl) (dbl)
## 1 2013 <1 year 0.034922 0.032553 0.037135
## 2 2013 1-4 years 0.003233 0.003312 0.003158
## 3 2013 5-9 years 0.001410 0.001397 0.001422
## 4 2013 10-14 years 0.000916 0.000894 0.000937
## 5 2013 15-19 years 0.001230 0.001102 0.001351
## 6 2013 20-24 years 0.001563 0.001305 0.001807
## 7 2013 25-29 years 0.001780 0.001490 0.002057
## 8 2013 30-34 years 0.002150 0.001771 0.002517
## 9 2013 35-39 years 0.002631 0.002117 0.003132
## 10 2013 40-44 years 0.003163 0.002478 0.003834
## .. ... ... ... ... ...
names(DeathData) <- c("Year", "Ages", "Both_Sexes", "Females", "Males")
TidyData <- gather(DeathData, "Sex","DeathRate", 3:5)
TidyData$Ages <- factor(TidyData$Ages, levels = c("<1 year", "1-4 years", "5-9 years", "10-14 years", "15-19 years", "20-24 years", "25-29 years", "30-34 years", "35-39 years", "40-44 years", "45-49 years", "50-54 years", "55-59 years", "60-64 years", "65-69 years", "70-74 years", "75-79 years", "80-84 years", "85-89 years", "90-94 years", "95-99 years", "100+ years"))
ggplot(TidyData, aes(x=Sex, y=DeathRate, fill = Ages)) + geom_bar(stat = "identity", position="dodge") + theme(axis.title.x=element_text(face="bold", size=15), axis.title.y=element_text(face="bold", size=15), axis.text=element_text(face="bold", size = 10)) + ggtitle("Death Rate") + theme(plot.title=element_text(face="bold", size=20)) + theme(legend.title=element_text(face="bold", size=10,color="white"), legend.background=element_rect(fill="black"), legend.text=element_text(face="bold", color="white", size=8))
* This is a bar plot that is separated by sex(Males, Females, Both). We can see by the graph that teh death rate increases the older you get (As it should be). It is a little scary that infants below the age of 1 do have a little high of a death rate. The graph is a really good depiction of how the rate changes as you get older.