Purpose

This short vignette is used to extract the country colors from the dominant colors of their respective flags. This colors are used in the chord diagrams.

library(wateReview)

Country ISO codes

First, we report the country ISO Alpha-2 codes and their names.

iso_codes <- c("ar", "bs", "bb", "bz", "bo", "br", "cl", "co", "cr", "cu", "ec", "sv", "gt", "ht", "hn", "jm", "mx", "ni", "pa", "py", "pe", "uy", "ve")
country_names <- c("Argentina", "Bahamas", "Barbados", "Belize", "Bolivia", "Brazil", "Chile", "Colombia", "Costa Rica", "Cuba", "Ecuador", "El Salvador", "Guatemala", "Haiti", "Honduras", "Jamaica", "Mexico", "Nicaragua", "Panama", "Paraguay", "Peru", "Uruguay", "Venezuela")

We then sequentially apply the get_topColors() function and leverage Wikipedia data collected from this repository.

countryColors <- lapply(iso_codes, get_topColors)
countryColors <- do.call(rbind, countryColors)
countryColors <- gsub("#000", "#000000", countryColors)
countryColors <- as.data.frame(countryColors)
countryColors$country_names <- country_names
head(countryColors)
#>        V1      V2      V3 country_names
#> 1 #74acdf #ffffff #f3f8fc     Argentina
#> 2 #00abc9 #000000 #fae042       Bahamas
#> 3 #00267f #ffc726 #000000      Barbados
#> 4 #003f87 #ce1126 #ffffff        Belize
#> 5 #007934 #d52b1e #ffe000       Bolivia
#> 6 #009b3a #fedf00 #002776        Brazil