Importing the data downloaded from Gapminder
World_population<-read_csv("C:/Users/user/Downloads/population_total.csv")
world_gdp_percapita<-read_csv("C:/Users/user/Downloads/ny_gdp_pcap_cd.csv")
world_life_expectancy<-read_csv("C:/Users/user/Downloads/life_expectancy_years.csv")
east_africa_population<-World_population %>%
pivot_longer(names_to = "year", values_to = "population",cols = -country) %>%
filter(year %in% c(1960:2020)) %>%
filter(country %in% c("Rwanda","Uganda", "Kenya","Burundi","Tanzania"))
east_africa_GDP_per_capita<-world_gdp_percapita %>%
pivot_longer(names_to = "year", values_to = "GDP",cols = -country)%>%
filter(year %in% c(1960:2020)) %>%
filter(country %in% c("Rwanda","Uganda", "Kenya","Burundi","Tanzania"))
east_africa_life_expectancy<-world_life_expectancy %>%
pivot_longer(names_to = "year", values_to = "life_exp",cols = -country)%>%
filter(year %in% c(1960:2020)) %>%
filter(country %in% c("Rwanda","Uganda", "Kenya","Burundi","Tanzania"))
East_african_data<-full_join(east_africa_population,east_africa_life_expectancy, by = c("country","year"))%>%
full_join(east_africa_GDP_per_capita,by = c("country","year") )
plot<-East_african_data %>%
mutate(year = as.Date(year,"%Y")) %>%
ggplot( aes(GDP, life_exp, size = population, colour = country)) +
geom_point(show.legend = FALSE) +
theme(legend.position = "none")+
scale_size(range = c(2, 12)) +
scale_x_log10() +
# Here comes the gganimate specific bits
labs(title = 'Year: {frame_time}', subtitle = "Comparison of East African countries since 1960 until 2020, in terms of GDP per Capita, \n Life Expectancy and population. Data source: Gapminder.org", x = 'GDP per capita (in Current US$) \n \n pplotted by Birasafab', y = 'life expectancy (in years)') +
transition_time(year) +
ease_aes('linear')+
enter_fade() +
exit_fade()+
theme_light()+
geom_text(aes(label = country), hjust = 1.1)
#+ shadow_wake(wake_length = 0.1, alpha = FALSE)
plot
