This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.
data <- read.csv("NCHS_-_Leading_Causes_of_Death__United_States.csv")
data
data2 <- read.csv("NCHS_-_Leading_Causes_of_Death__United_States2.csv")
data2
data3 <- read.csv("NCHS_-_Leading_Causes_of_Death__United_States3.csv")
data3
data4 <- read.csv("NCHS_-_Leading_Causes_of_Death__United_States4.csv")
data4
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)
library(ggplot2)
library(ggthemes)
library(grafify)
new_data2 <- data2 %>%
select(c(Year, Deaths, Age.adjusted.Death.Rate))
ggplot(new_data2) +
geom_line(aes(y = Deaths, x = Year, color = "Deaths")) +
labs(y = "Total Amount", x = "Year",
title = "Amount of Deaths For All Causes Over Time",
color = "Amount of Deaths (All Causes)") +
scale_color_manual(labels = c("Amount of Deaths (All Causes)"), values = c("red")) +
theme_clean()
ggplot(new_data2) +
geom_line(aes(y = Age.adjusted.Death.Rate, x = Year, color = "Age Adjusted Death Rate")) +
labs(y = "Total Amount", x = "Year",
title = "Age Adjusted Death Rate For All Causes Over Time",
color = "Age Adjusted Death Rate (All Causes)") +
scale_color_manual(labels = c("Age Adjusted Death Rate (All Causes)"), values = c("blue")) +
theme_clean()
ggplot(data4, aes(x = Deaths, y = Cause.Name, fill = Cause.Name))+
geom_bar(stat = "Identity")+
labs(y = "Cause Name", x = "Average Amount of Deaths", title = "Average Amount of Deaths For Each Cause From 1999-2017", fill = "Cause Name")+
theme_minimal()+
scale_fill_grafify(palette = "muted")
ggplot(data4, aes(x = Age.adjusted.Death.Rate, y = Cause.Name, fill = Cause.Name))+
geom_bar(stat = "Identity")+
labs(y = "Cause Name", x = "Average Age Adjusted Death Rate", title = "Average Age Adjusted Death Rate For Each Cause From 1999-2017", fill = "Cause Name")+
theme_minimal()+
scale_fill_grafify(palette = "muted")
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Cmd+Option+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Cmd+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.