MORTALITY RATE DATA ANALYSIS

MORTALITY RATE BY COUNTRY AND CAUSE
0

TIDYVERSE

EASY

last hacked on Feb 20, 2019

Load packages

# Load dplyr package
# Load readr package
library(dplyr)
library(readr)

Set working directory and assign df

# Set working directory assign and assign df
df <- read_csv('/home/computer/projects/nood-tidy/mortality/mortality.csv')

Suicide in Japan in 1999 using pipe operator

# Pipe to look at Suicide in 1999
df %>%
  select(country, country_code, year, `Suicide (%)`) %>%
  filter(country == `Japan`, year == 1999)

ggplot2

# Filter suicide in Japan
jap_sui <- filter(df, country == "Japan", year > 1999, `Suicide (%)`)

# Use ggplot function to look at graph
ggplot(data = jap_sui) +
  geom_line(mapping = aes(x = `Suicide (x)`, y = year))

Suicide in the United states in 1999 using pipe operator

df %>%
  select(country, country_code, year, `Suicide (%)` ) %>%
  filter(country_code == "United States", year == 1999)

Filter suicide and assign as usa_sui and graph

usa_df <- filter(df, country == "United States", year > 1999, `Suicide (%)`)

ggplot(data = usa_sui) +
  geom_line(mapping = aes(x = year, y = `Suicide (%)`))

Cardiovacular disease in the US for year 2001

df %>%
  select(country, country_code, year, `Cardiovascular diseases 
  (%)`) %>%
  filter(country_code == "USA", year 2000)

Filter CA assign as usa_cardio, looking at year 1999 above

usa_cardio <- filter(df, country_code == "USA", year > 1999, `Cardiovascular diseases (%)`)

ggplot(data = usa_cardio) +
 geom_line(mapping = aes(x = year, y = `Cardiovascular diseases (%)`))

Cardiovascular disease in Mexico in 2001

df %>%
  select(country, country_code, `Cardiovascular diseases (%)`) 
  %>%
  filter(country == "Mexico", year == 2001) 

Filter CA and assing as mx_cardio, looking at year 1999 above and graph

mx_cardio <- filter(df, country == "Mexico", year > 1999, `Cardiovascular diseases (%)`)

ggplot(data = mx_cardio) +
 geom_line(mapping = aes(x = year, y = `Cardiovascular diseases (%)`))


COMMENTS


## variance explained * <http://varianceexplained.org/>
## Reference links * <https://dplyr.tidyverse.org/> * <https://dplyr.tidyverse.org/reference/select.html> * <https://r4ds.had.co.nz/transform.html>





keep exploring!

back to all projects