library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.8
## ✓ tidyr   1.2.0     ✓ stringr 1.4.0
## ✓ readr   2.1.2     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(maps)
## 
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
## 
##     map
hofstede <- read_delim("http://geerthofstede.com/wp-content/uploads/2016/08/6-dimensions-for-website-2015-08-16.csv",
                       delim = ";") %>%
    select(-ltowvs, -ivr) %>%
    mutate_at(-1:-2, function(c) as.numeric(c)) %>%
    pivot_longer(-1:-2, names_to = "Dimension", values_to = "Score")
## Rows: 111 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ";"
## chr (8): ctr, country, pdi, idv, mas, uai, ltowvs, ivr
## 
## ℹ 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.
## Warning in (function (c) : NAs introduced by coercion
## Warning in (function (c) : NAs introduced by coercion
## Warning in (function (c) : NAs introduced by coercion
## Warning in (function (c) : NAs introduced by coercion
netherlands <- filter(hofstede, country == "Netherlands") %>%
    select(Dimension, nl_score = Score)

dutchness <- left_join(hofstede, netherlands) %>%
    filter(country != "South Africa") %>%
    mutate(dif = abs(Score - nl_score),
           country = str_replace(country, "U.S.A.", "USA"),
           country = str_replace(country, "Great Britain", "UK"),
           country = str_replace(country, "Czech Rep", "Czech Republic"),
           country = str_replace(country, "Korea South", "South Korea"),
           country = str_replace(country, "South Africa white", "South Africa")) %>%
    group_by(country) %>%
    summarise(Dutchness = sum(dif)) %>%
    rename(region = country) %>%
    filter(!is.na(Dutchness))
## Joining, by = "Dimension"
country_df <- map_data("world")
dutchness$Dutchness <- max(dutchness$Dutchness) - dutchness$Dutchness

left_join(country_df, dutchness) %>%
    ggplot(aes(long, lat, group = group, fill = Dutchness)) +
    geom_polygon(colour = alpha("black", 1/2), size = .1) +
    scale_fill_gradient(low = "red", high = "green") +
    coord_equal() +
    theme_void() +
    labs(title = "Dutchness using Hofstede's Cultural Dimensions",
         subtitle = "Using total absolute difference between PDI, IDV, MAS and UAI",
         caption = "Code: Peter Prevos\nData source: hofstede-insights.com") +
    annotate(geom="text", x = 6, y = -30, cex = 1,
             label = "European\npopulation")
## Joining, by = "region"

ggsave("dutchness.png", width = 1920, height = 1080, bg = "white", units = "px")