- Business & Data Research
- Posts
- Descriptive Analysis - Life Expectancy Details
Descriptive Analysis - Life Expectancy Details
Descriptive Analysis
Life Expectancy Based On Regions
This business case describes about the life expectancy of the people starting from 1950 till 2011 and through this analysis, we could understand the average life span based on their life styles, food habits… etc
Required Packages for the analysislibrary(dplyr)
library(ggplot2)
library(patchwork)
library(janitor)
library(gapminder)
library(thematic)
data <- gapminder::gapminder %>%
janitor::clean_names() %>%
mutate(
# Reformat to factor instead of character
id = levels(continent)[as.numeric(continent)],
continent = forcats::fct_reorder(continent, life_exp))
color_palette <- thematic::okabe_ito(5)
names(color_palette) <- unique(data$continent)
base_size <- 18
mean_life_exps <- data %>%
group_by(continent, year, id) %>%
summarise(mean_life_exp = mean(life_exp)) %>%
ungroup()
line_chart <- mean_life_exps %>%
ggplot(aes(x = year, y = mean_life_exp, col = continent)) +
geom_line(linewidth = 2.5) +
geom_point(size = 4) +
theme_minimal(base_size = base_size) +
labs(x = element_blank(),y = 'Life expectancy (years)',
title = 'Life expectancy starting from 1950 till 2011'
) +
theme(
text = element_text(
color = 'grey'
),
legend.position = 'none',
panel.grid.minor = element_blank(),
plot.title.position = 'plot'
) +
scale_color_manual(values = color_palette)