where top 10 countries with highest life expectancy and top 10 countries with highest infant mortality. # Comparing how the life expectancy will be better/higher if there is less infant mortality. There can be multiple #factors but we can assume that one of the them is the medical facilites provides better services to its citizen leaving in that country
library(rmarkdown)
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.3.3
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Warning: package 'ggplot2' was built under R version 3.3.3
## Warning: package 'purrr' was built under R version 3.3.3
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag(): dplyr, stats
countrytest <- read_csv("C:/Users/senet/Desktop/COLLEGE/St.Martins Classes/CSC 463 Data Visualization Tools/R/countrytest.csv")
## Parsed with column specification:
## cols(
## country = col_character(),
## life_exp = col_double(),
## inf_mort = col_double()
## )
a1 = ggplot(countrytest, aes(x=life_exp, y=inf_mort))+geom_point()
a1
a2=a1 + geom_point(aes(color=country))
a2
a3=a2 + geom_smooth(method="loess", se=F) +
xlim(c(0, 130)) +
ylim(c(0, 130)) +
labs(subtitle="Life Expectancy Vs Infant Mortality",
x="Life Expectancy",
y="Infant Mortality",
title="Scatterplot",
caption = "Source: Country Dataset")
a3
a4=a2 + geom_smooth(method="lm", se=F) +
xlim(c(0, 130)) +
ylim(c(0, 130)) +
labs(subtitle="Life Expectancy Vs Infant Mortality",
x="Life Expectancy",
y="Infant Mortality",
title="Scatterplot",
caption = "Source: Country Dataset")
a4
## Warning: Removed 13 rows containing missing values (geom_smooth).
#the above lines of code can be changed to draw the line of best fit by setting method=‘lm’