Let’s use our libraries(tidyverse, countrycode) and read our dateset
require(tidyverse)
## Loading required package: tidyverse
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.2
## ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── 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
require(countrycode)
## Loading required package: countrycode
hr <- read.csv("../Datasets/hr_status_icerd.csv")
view(hr)
hr_gl <- hr%>% #nolint
add_row(iso2="GL", member="GreenLand", state.party = 1, year.ratification.or.accession= 1971, signatory=0, no.action=0,status="state party") #nolint
hr = hr_gl #nolint
view(hr)
Now we start to create our map.
First step creating our dataframe
wmap <- map_data("world")
head(wmap)
## long lat group order region subregion
## 1 -69.89912 12.45200 1 1 Aruba <NA>
## 2 -69.89571 12.42300 1 2 Aruba <NA>
## 3 -69.94219 12.43853 1 3 Aruba <NA>
## 4 -70.00415 12.50049 1 4 Aruba <NA>
## 5 -70.06612 12.54697 1 5 Aruba <NA>
## 6 -70.05088 12.59707 1 6 Aruba <NA>
2nd step:
worldplot <- ggplot() +
geom_polygon(data = wmap, aes(x = long, y = lat, group = group)) +
coord_fixed(1.3)
worldplot
Congrats! you’ve created your map.