Load libraries and data set

library(ggplot2)
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
## ✔ lubridate 1.9.3     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.1
## ── 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)
library(patchwork)
world_happiness <- read.csv("https://raw.githubusercontent.com/pjlombardo/SigmaXiWorkshop-2023/main/data/worldHappiness.csv", header = T)

Preview of world_happiness data set

head(world_happiness)
##   region      long      lat group order Ladder.score Social.support
## 1  Aruba -69.89912 12.45200     1     1           NA             NA
## 2  Aruba -69.89571 12.42300     1     2           NA             NA
## 3  Aruba -69.94219 12.43853     1     3           NA             NA
## 4  Aruba -70.00415 12.50049     1     4           NA             NA
## 5  Aruba -70.06612 12.54697     1     5           NA             NA
## 6  Aruba -70.05088 12.59707     1     6           NA             NA
##   Healthy.life.expectancy Freedom.to.make.life.choices Generosity
## 1                      NA                           NA         NA
## 2                      NA                           NA         NA
## 3                      NA                           NA         NA
## 4                      NA                           NA         NA
## 5                      NA                           NA         NA
## 6                      NA                           NA         NA
##   Perceptions.of.corruption Ladder.score.in.Dystopia
## 1                        NA                       NA
## 2                        NA                       NA
## 3                        NA                       NA
## 4                        NA                       NA
## 5                        NA                       NA
## 6                        NA                       NA

Map of Perceptions of Corruption by Country using world_happiness data set

ggplot(data = world_happiness %>% arrange(order),
       aes(x=long,y=lat,
           group = group,
           fill=Perceptions.of.corruption))+
  geom_polygon(color='black',alpha=.6,linewidth=.1)+
    coord_cartesian(ylim=c(-55,90))+
    theme_bw()+
    scale_fill_gradientn("Perception of\nCorruption",colors = rev(brewer.pal(9,name="RdYlBu")),
                         na.value='black')+
    labs(x="Longitude", y = "Latitude",
         title = "Perceptions of Corruption by Country",
         subtitle = "(Data provided by World happiness Report)",
         caption = "Note: Antarctica has been removed, but rest assured\n that penguins are generally pretty happy.")

Map of Healthy Life Expectancy by Country using world_happiness data set

ggplot(data = world_happiness %>% arrange(order),
       aes(x=long,y=lat,
           group = group,
           fill=Healthy.life.expectancy))+
  geom_polygon(color='black',alpha=.6,linewidth=.1)+
    coord_cartesian(ylim=c(-55,90))+
    theme_bw()+
    scale_fill_gradientn("Healthy life\nExpectancy",colors = rev(brewer.pal(9,name="PuBuGn")),
                         na.value='black')+
    labs(x="Longitude", y = "Latitude",
         title = "Healthy Life Expectancy by Country",
         subtitle = "(Data provided by World happiness Report)",
         caption = "Note: Antarctica has been removed, but rest assured\n that penguins are generally pretty happy.")