The benefits of data visualizations include assisting users with better conveying a story and the audience with receiving the most critical data This is beneficial for both decision making and information sharing. Specifically, this report shares information relating to the GDP Per Capita and life expectancy of all countries. I specifically focused on East African countries with years ranging between 2002-2007. The rational behind the temporal focus is to assess the global impacts of the 9/11 attacks and the subsequent armed conflicts that occurred in the middle east as a result. Considering that a considerable amount of East African youth ( specifically young women or in some cases minor girls with Ethiopia contributing to a majority of these migrations) travel to the middle east for labor purposes, I believe this data assessment will provide some insight in the evolution of these variables.
The following plots include the ‘Plotly’ package, which is a Javascript based software that allows for interactive plots. The package intercedes between R and Javascript to provide additional information when the audience clicks on a given data point. For example, when clicking on the Ethiopia data point for the East Africa’s Economic Development 2000 2007 graph, the 2000 graph indicates that Ethiopia’s life expectancy was 51 years old with a GPD per Capita of $530 while the 2007 graph shows a small improvement with an average life expectancy of 53 and GPDPC of $691. The size of the data point reflects the expansive population relative to other countries. There is little growth in GPDPC with the average life expectancy of the population barely reaching middle age. # Task 2: Interactive plots
Regular Plot
library(dplyr)
library(ggplot2)
library(dplyr)
library(scales)
library(viridis)
## Loading required package: viridisLite
##
## Attaching package: 'viridis'
## The following object is masked from 'package:scales':
##
## viridis_pal
library(plotly)
# Filtering data for Ethiopia
ethiopia_data <- gapminder %>%
filter(country == "Ethiopia")
# Creating plot for Ethiopia
ethiopia_plot <- ggplot(data = ethiopia_data,
mapping = aes(x = year, y = lifeExp,
color = continent, size = pop, text = paste("Country: ", country))) +
geom_point() +
scale_size_continuous(labels = comma) +
scale_color_viridis_d(option = "plasma", end = 0.9) +
labs(x = "Year", y = "Life Expectancy",
color = "Continent", size = "Population",
title = "Life Expectancy in Ethiopia (All Years)",
subtitle = "Life Expectancy Trends Over the Years",
caption = "Source: The Gapminder Project") +
theme_minimal() +
theme(panel.grid.minor = element_blank())
ethiopia_plot_interactive <- ggplotly(ethiopia_plot, tooltip = "text")
ethiopia_plot_interactive
Interactive Plot
library(ggplot2)
library(plotly)
library(scales)
library(ggplot2)
library(plotly)
library(scales)
# Filtering data for East African countries and years 2000 and 2007
east_africa_data <- gapminder %>%
filter(country %in% c("Ethiopia", "Eritrea", "Somalia", "Kenya", "Sudan") & (year %in% c(2002, 2007)))
East_Plot <- ggplot(data = east_africa_data,
mapping = aes(x = gdpPercap, y = lifeExp,
color = country, size = pop, text = paste("Country: ", country, "<br>Population: ", pop))) +
geom_point() +
scale_x_log10(labels = dollar_format(accuracy = 1)) +
scale_size_continuous(labels = comma) +
scale_color_viridis_d(option = "plasma", end = 0.9) +
labs(x = "GDP per capita", y = "Life expectancy",
color = "Country", size = "Population",
title = "Economic Development, 2002 and 2007",
subtitle = "GDP Per Capita vs Life Expectancy",
caption = "Source: The Gapminder Project") +
facet_wrap(vars(year))
East_Plot <- East_Plot +
theme_minimal() +
theme(panel.grid.minor = element_blank())
new_East_Plot <- East_Plot +
theme_minimal(base_family = "Roboto Condensed", base_size = 12) +
theme(panel.grid.minor = element_blank(),
plot.title = element_text(face = "bold", size = rel(1.6)),
plot.subtitle = element_text(face = "plain", size = rel(1.2), color = "grey70"),
plot.caption = element_text(face = "italic", size = rel(0.6),
color = "grey70", hjust = 0),
legend.title = element_text(face = "bold"),
strip.text = element_text(face = "bold", size = rel(1.1), hjust = 0),
axis.title = element_text(face = "bold"),
axis.title.x = element_text(margin = margin(t = 10), hjust = 0),
axis.title.y = element_text(margin = margin(r = 10), hjust = 1))
new_East_Plot <- new_East_Plot +
theme(strip.background = element_rect(fill = "grey90", color = NA),
panel.border = element_rect(color = "grey90", fill = NA))
country_interactive_plot <- ggplotly(new_East_Plot, tooltip = "text")
country_interactive_plot
htmlwidgets::saveWidget(country_interactive_plot, "country_interactive_plot.html")