U.S. News & World Report conducted a global study to rank the most unique countries worldwide. The rankings project measures global perceptions and defines countries in terms of several qualitative characteristics, such as impressions that have the potential to increase trade, travel, and investment (https://www.usnews.com/news/best-countries/articles/methodology). The results identified the top four countries: Egypt, India, the United Arab Emirates, and Qatar. For this reason, I selestudycted these countries. The dataset had some interesting elements. All except Egypt were ranked as high-income. Egypt ranked as lower middle income.
Countries in the Global Study
Load libraries
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.5.1 ✔ 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(RColorBrewer)
Load the dataset
setwd("C:/Users/naomi/OneDrive/Desktop/Desktop of 11-08-2022/Community College Classes/DATA 110/Nations")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.
tibble(nations)
# A tibble: 5,275 × 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
7 AD AND Andorra 2004 NA 78337 10.9 2
8 AD AND Andorra 2010 NA 84419 9.8 1.7
9 AD AND Andorra 2001 NA 67770 11.8 2.1
10 AD AND Andorra 2002 NA 71046 11.2 2.1
# ℹ 5,265 more rows
# ℹ 2 more variables: region <chr>, income <chr>
Filter Data
nations <- nations %>%mutate(desired_countries =case_when( country %in%c("Egypt, Arab Rep.", "Qatar", "United Arab Emirates", "India") ~ country,!(region %in%c("Latin America & Caribbean", "East Asia & Pacific", "Europe & Central Asia", "Sub-Saharan Africa", "Middle East & North Africa")) ~"Others",TRUE~NA_character_ )) %>%filter(!is.na(desired_countries)) %>%mutate(group =factor(desired_countries, levels =rev(c("Egypt", "Arab Rep.", "Qatar", "United Arab Emirates", "India"))))
`summarise()` has grouped output by 'region'. You can override using the
`.groups` argument.
Visual display of GPD in Trillions by Region Over the Years
ggplot(grouped_nations, aes(x = year, y = GDP, fill = region)) +geom_area(color ="white") +scale_fill_brewer(palette ="Set2") +labs(title ="GDP in Trillions by Region Over Years \n A Longitudinal Review",caption ="Source: World Bank") +xlab("Years") +ylab("GDP in Trillions") +theme_classic() +theme(text =element_text(face ="bold", color ="darkgreen", family ="serif"),geom_line(alpha =0.9, color ="white"),axis.line =element_line(color ="darkgreen", linewidth =1.0, linetype ="solid"),legend.position =c(0.2, 0.7)) +guides(fill =guide_legend(title ="Region", title.position ="top", title.hjust =0.5))
Warning: A numeric `legend.position` argument in `theme()` was deprecated in ggplot2
3.5.0.
ℹ Please use the `legend.position.inside` argument of `theme()` instead.