4  Results by country

Code
# Import packages and working dataset
library(tidyverse)
library(haven)
library(plotly)
library(gt)

df_es <- readRDS("./data/ES2_NameSurvey_2025-09-09.RDS")

# Get weighted mean using the survey weight variable
get_mean <- function(var_es, wgt_es){
    weighted.mean({{var_es}}, w = {{wgt_es}}, na.rm = TRUE)
}

5 Results by country

Important

Don’t Know: All the rates in the tables below include ‘Don’t Know’ in the denominator.

Ladder: This column shows the mean value for the question on status. The original scale was inverted and rescaled so here higher values denote higher positions in the ladder (from 0 to 1).

Code
# Function to get congruence rates for specific variables and countries
get_rank <- function(country, ...){

    selected_vars <- c(...)

    tb_country <- 
      df_es |>
        group_by(country_survey, country_name, Name) |>
        summarise(across(all_of(selected_vars), ~get_mean(., Weging)), .groups = 'drop') |>
        filter(country_survey == country) |>
        arrange(country_name)

    openxlsx::write.xlsx(tb_country, file = paste0("./data/rankings/", country, ".xlsx"))

    gt(tb_country) |> 
      fmt_number(columns = everything(), decimals = 2) |> 
      fmt_percent(columns = starts_with("cong_") ,decimals = 0) |>
      sub_missing() |>
      cols_label_with(fn =  ~str_remove(., "cong_|_adj")) |>
      opt_interactive(use_filters = TRUE, use_page_size_select = TRUE)
  }

country_variables <- c("cong_sex", "skin_adj", "cong_country", "cong_region", "ladder_adj", "religiosity")

5.1 Belgium

Code
get_rank("Belgium", country_variables)

5.2 Czech Republic

Code
get_rank("Czech Republic", country_variables)

5.3 Germany

Code
get_rank("Germany", country_variables)

5.4 Hungary

Code
get_rank("Hungary", country_variables)

5.5 Ireland

Code
get_rank("Ireland", country_variables)

5.6 Netherlands

Code
get_rank("The Netherlands", country_variables)

5.7 Spain

Code
get_rank("Spain", country_variables)

5.8 Switzerland

Code
get_rank("Switzerland", country_variables)

5.9 UK

Code
get_rank("UK", country_variables)