Nations project

Author

Aminata Diatta

load the dataset

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
setwd("C:/Users/satad/Desktop/data110")
nations <- read_csv("nations.csv")
Rows: 5275 Columns: 10
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): iso2c, iso3c, country, region, income
dbl (5): year, gdp_percap, population, birth_rate, neonat_mortal_rate

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(nations)
# A tibble: 6 × 10
  iso2c iso3c country  year gdp_percap population birth_rate neonat_mortal_rate
  <chr> <chr> <chr>   <dbl>      <dbl>      <dbl>      <dbl>              <dbl>
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  
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
# ℹ 2 more variables: region <chr>, income <chr>

Let’s make the gdp_percap in trillions of dollard

nations2 <- nations %>%
  mutate(nations,
         gdp_pertrillion =(gdp_percap*population)/10^12)
  view(nations2)

let’s draw the first chart by choosing France,Dominica,Mexico, and Maldives as a favorites countries.

library(ggplot2)
favorites_country <- nations2 %>%
  filter(country == "France"|country == "Dominica"|country == "Mexico"|country == "Maldives")
view(favorites_country)

Start the first chart

library(dplyr)
chart1 <- favorites_country |>
  ggplot() + geom_point(aes(x = year , y = gdp_pertrillion, color = country))+ scale_color_brewer(palette = "Set1") + geom_line(aes(x = year , y = gdp_pertrillion , color = country)) +
  labs( title = " The economy of my four favorites country", x ="Year" , y = "Gross Domestic Product in Trillions" , color = "country") 
chart1
Warning: Removed 11 rows containing missing values (`geom_point()`).
Warning: Removed 11 rows containing missing values (`geom_line()`).

comments :

Upon reviewing the first chart , it is evident that certain countries like Dominica and Maldives reached a trillion-dollar GDP after 2015. In contrast, countries like France and Mexico achieved this milestone prior to the year 2000. Examining the graph make me notice that the economic of France and Mexico growth over the year. France and Mexico boast larger and more diversified economies compared to Dominica and Maldives. Factors such as population size, industrial development, international trade, and government policies likely contributed to their earlier attainment of a trillion-dollar GDP.

By using “group_by” , let’s make chart2

region_and_year <- nations2 |> 
  group_by(region, year) |> 
  summarise(gdp_pertrillion = sum(gdp_pertrillion, na.rm = TRUE))
`summarise()` has grouped output by 'region'. You can override using the
`.groups` argument.

let’s start the second chart

chart2 <- region_and_year |>
  ggplot() + geom_line(aes(x = year, y = gdp_pertrillion)) +
  geom_area(aes(x = year, y = gdp_pertrillion, fill = region), color = "white") +
  scale_fill_brewer(palette = "Set2") +
  labs(title = "Gross Domestic Product by World Bank Region", 
       x = "Year",
       y = "Gross Domestic Product in Trillion",
      color = "Region")
chart2

Comments :

Analyzing GDP across World Bank regions provides valuable insights into each area’s economic performance. The second graph highlights the consistently significant GDP of the East Asia and Pacific region compared to others. This comes as no surprise, given the robust economies of major contributors like China and Japan. China’s global export dominance is demonstrated by companies like Shein and Temu exporting various products, particularly textiles. Between 2010 and 2015, there was accelerated economic growth in regions like Europe & Central Asia and North America, contrasting with the slower growth observed in South Asia, the Middle East & North Africa, Latin America & the Caribbean, and Sub-Saharan Africa