iso2c iso3c country year gdp_percap population birth_rate neonat_mortal_rate
1 AD AND Andorra 1996 NA 64291 10.9 2.8
2 AD AND Andorra 1994 NA 62707 10.9 3.2
3 AD AND Andorra 2003 NA 74783 10.3 2.0
4 AD AND Andorra 1990 NA 54511 11.9 4.3
5 AD AND Andorra 2009 NA 85474 9.9 1.7
6 AD AND Andorra 2011 NA 82326 NA 1.6
region income
1 Europe & Central Asia High income
2 Europe & Central Asia High income
3 Europe & Central Asia High income
4 Europe & Central Asia High income
5 Europe & Central Asia High income
6 Europe & Central Asia High income
nations$gdp_in_trillions <- (nations$gdp_percap * nations$population) /1e12bordering_countries <- nations[ nations$country %in%c("Ukraine", "Poland", "Romania", "Hungary", "Russian Federation","Moldova", "Slovakia", "Belarus"), ]# Plot GDP trends with ggplot2ggplot(bordering_countries, aes(x = year, y = gdp_in_trillions, color = country)) +geom_point() +geom_line() +scale_color_brewer(palette ="Set1") +theme_minimal() +labs(title ="GDP Trends for Ukraine and Bordering Countries", x ="Year", y ="GDP (Trillions)")
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_line()`).
# Identify rows with missing values in the relevant columnsbordering_countries[!complete.cases(bordering_countries), ]
iso2c iso3c country year gdp_percap population birth_rate
2033 HU HUN Hungary 1990 NA 10373988 12.1
neonat_mortal_rate region income
2033 13.6 Europe & Central Asia High income: OECD
gdp_in_trillions
2033 NA
# Grouping by region and year, then summing GDPregional_gdp <-aggregate(gdp_in_trillions ~ region + year, data = nations, sum)# Plotting the area chartggplot(regional_gdp, aes(x = year, y = gdp_in_trillions, fill = region)) +geom_area(color ="white", linewidth =0.2) +scale_fill_brewer(palette ="Set2") +theme_minimal() +labs(title ="Regional GDP Trends", x ="Year", y ="GDP (Trillions)")