# Allow computer accesses functions
library(gapminder)
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.2.3
##
## 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(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.3
ggplot(data = gapminder,
mapping = aes(x = year,
y = lifeExp))+
labs(y = "Life expecttancy at birth in years",
title = "Life Expectancy on Five Continents over Time",
caption = "Source: Gapminder")+
geom_line(mapping = aes(group = country), color = "gray")+
geom_smooth(method = "loess", se = FALSE, linewidth = 1.1 )+
scale_y_log10(labels = scales::dollar)+
facet_wrap(~continent, nrow = 1)
## `geom_smooth()` using formula = 'y ~ x'
As the results, there are 5 continents: Africa, Americas, Asia, Europe, and Oceania, which shows each country’s life expectancy trajectory over time. Horizontal line represents year from 1950 to 2000, and Vertical line represents Life Expectancy in year. The lines on each graph tend to increase year to year, which means the factors that effect in increasing life expectancy, it probably could be quality of life improvements, global health, economic, innovation, capital accumulation, and so on.