Compensation of employees (% of expense)

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Albania Albania 20.5 +14.4% 44
United Arab Emirates United Arab Emirates 32.2 +6.47% 21
Argentina Argentina 12.9 +12.8% 68
Armenia Armenia 19.3 +1.38% 48
Austria Austria 10.1 +3.99% 75
Burkina Faso Burkina Faso 40.7 +14.8% 11
Bulgaria Bulgaria 18 +12.9% 54
Bahamas Bahamas 25.9 +8.89% 33
Bosnia & Herzegovina Bosnia & Herzegovina 25.8 -0.813% 34
Belarus Belarus 14.1 +5.38% 67
Brazil Brazil 6.58 -2.19% 84
Botswana Botswana 50.4 0% 1
Canada Canada 10.5 +2.47% 74
Switzerland Switzerland 7.02 +0.452% 83
Chile Chile 19.9 +2.59% 47
Côte d’Ivoire Côte d’Ivoire 23.3 +3.94% 38
Colombia Colombia 9.83 +3.78% 76
Costa Rica Costa Rica 26.8 -4.24% 31
Cyprus Cyprus 27.2 -2.11% 29
Denmark Denmark 11 +2.23% 72
Dominican Republic Dominican Republic 34.3 +1.31% 18
Spain Spain 5.91 -0.996% 85
Estonia Estonia 16.6 +4.14% 59
Ethiopia Ethiopia 14.8 +5.02% 62
Finland Finland 7.15 -11.3% 82
Fiji Fiji 27.7 -0.838% 28
France France 17.6 +1.38% 55
United Kingdom United Kingdom 15.6 +1.26% 60
Georgia Georgia 14.4 +14% 65
Guinea-Bissau Guinea-Bissau 38.4 -19% 15
Greece Greece 18.5 +2.26% 52
Guatemala Guatemala 32 +2.82% 22
Croatia Croatia 14.5 -2.19% 64
Iceland Iceland 23.8 -4.21% 36
Israel Israel 22.3 +4.72% 40
Italy Italy 10.9 -3.07% 73
Jordan Jordan 46 +1.65% 6
Kazakhstan Kazakhstan 5.16 -2.41% 86
Kenya Kenya 18.4 -12% 53
Kyrgyzstan Kyrgyzstan 43.6 -4.95% 7
Cambodia Cambodia 38.9 -5.23% 12
Kiribati Kiribati 31.4 -4.08% 25
South Korea South Korea 8.79 +10.8% 79
Sri Lanka Sri Lanka 18.9 -25.1% 50
Lithuania Lithuania 15.6 +3.29% 61
Luxembourg Luxembourg 20.5 +0.363% 45
Latvia Latvia 19.2 +10.6% 49
Macao SAR China Macao SAR China 33.4 +39.5% 20
Morocco Morocco 38.5 -2.1% 14
Moldova Moldova 9.48 -9.66% 77
Madagascar Madagascar 47.9 -11.9% 3
Mexico Mexico 9.2 -1.37% 78
North Macedonia North Macedonia 12.4 -0.607% 69
Malta Malta 26.8 -1.38% 30
Mauritius Mauritius 26.6 -13.1% 32
Malaysia Malaysia 29.6 +8.34% 26
Namibia Namibia 38.8 -9.52% 13
Nicaragua Nicaragua 32 -4.83% 23
Netherlands Netherlands 7.79 +1.51% 81
Norway Norway 14.7 -1.49% 63
Philippines Philippines 35 +3.98% 17
Papua New Guinea Papua New Guinea 11.2 -22.5% 71
Poland Poland 12.3 -2.03% 70
Portugal Portugal 21.1 +1.02% 43
Paraguay Paraguay 41.5 -12.5% 9
Rwanda Rwanda 14.3 -1.06% 66
Saudi Arabia Saudi Arabia 48.5 -3.43% 2
Senegal Senegal 37.1 +6.93% 16
Singapore Singapore 18.8 -6.54% 51
El Salvador El Salvador 40.9 +0.26% 10
San Marino San Marino 23.5 +6.26% 37
Somalia Somalia 42 -11.1% 8
Slovenia Slovenia 16.8 -0.491% 57
Togo Togo 31.7 +3.32% 24
Thailand Thailand 22.6 +6.73% 39
Tajikistan Tajikistan 24.8 -0.261% 35
Tonga Tonga 33.8 -9.86% 19
Turkey Turkey 20.4 +6.19% 46
Tanzania Tanzania 16.7 +4.46% 58
Uganda Uganda 17.4 +2% 56
Ukraine Ukraine 28.6 -13.5% 27
Uruguay Uruguay 22.2 +4.89% 41
United States United States 8.03 +1.22% 80
Uzbekistan Uzbekistan 21.3 -3.35% 42
Vanuatu Vanuatu 46.1 -1.73% 5
Samoa Samoa 46.1 -2.45% 4

                    
# Install missing packages
import sys
import subprocess

def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])

# Required packages
for package in ['wbdata', 'country_converter']:
try:
__import__(package)
except ImportError:
install(package)

# Import libraries
import wbdata
import country_converter as coco
from datetime import datetime

# Define World Bank indicator code
dataset_code = 'GC.XPN.COMP.ZS'

# Download data from World Bank API
data = wbdata.get_dataframe({dataset_code: 'value'},
date=(datetime(1960, 1, 1), datetime.today()),
parse_dates=True,
keep_levels=True).reset_index()

# Extract year
data['year'] = data['date'].dt.year

# Convert country names to ISO codes using country_converter
cc = coco.CountryConverter()
data['iso2c'] = cc.convert(names=data['country'], to='ISO2', not_found=None)
data['iso3c'] = cc.convert(names=data['country'], to='ISO3', not_found=None)

# Filter out rows where ISO codes could not be matched — likely not real countries
data = data[data['iso2c'].notna() & data['iso3c'].notna()]

# Sort for calculation
data = data.sort_values(['iso3c', 'year'])

# Calculate YoY absolute and percent change
data['value_change'] = data.groupby('iso3c')['value'].diff()
data['value_change_percent'] = data.groupby('iso3c')['value'].pct_change() * 100

# Calculate ranks (higher GDP per capita = better rank)
data['rank'] = data.groupby('year')['value'].rank(ascending=False, method='dense')

# Calculate rank change from previous year
data['rank_change'] = data.groupby('iso3c')['rank'].diff()

# Select desired columns
final_df = data[['country', 'iso2c', 'iso3c', 'year', 'value',
'value_change', 'value_change_percent', 'rank', 'rank_change']].copy()

# Optional: Add labels as metadata (could be useful for export or UI)
column_labels = {
'country': 'Country name',
'iso2c': 'ISO 2-letter country code',
'iso3c': 'ISO 3-letter country code',
'year': 'Year',
'value': 'GDP per capita (current US$)',
'value_change': 'Year-over-Year change in value',
'value_change_percent': 'Year-over-Year percent change in value',
'rank': 'Country rank by GDP per capita (higher = richer)',
'rank_change': 'Change in rank from previous year'
}

# Display first few rows
print(final_df.head(10))

# Optional: Save to CSV
#final_df.to_csv("gdp_per_capita_cleaned.csv", index=False)
                    
                
                    
# Check and install required packages
required_packages <- c("WDI", "countrycode", "dplyr")

for (pkg in required_packages) {
  if (!requireNamespace(pkg, quietly = TRUE)) {
    install.packages(pkg)
  }
}

# Load the necessary libraries
library(WDI)
library(dplyr)
library(countrycode)

# Define the dataset code (World Bank indicator code)
dataset_code <- 'GC.XPN.COMP.ZS'

# Download data using WDI package
dat <- WDI(indicator = dataset_code)

# Filter only countries using 'is_country' from countrycode
# This uses iso2c to identify whether the entry is a recognized country
dat <- dat %>%
  filter(countrycode(iso2c, origin = 'iso2c', destination = 'country.name', warn = FALSE) %in%
           countrycode::codelist$country.name.en)

# Ensure dataset is ordered by country and year
dat <- dat %>%
  arrange(iso3c, year)

# Rename the dataset_code column to "value" for easier manipulation
dat <- dat %>%
  rename(value = !!dataset_code)

# Calculate year-over-year (YoY) change and percentage change
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(
    value_change = value - lag(value),                              # Absolute change from previous year
    value_change_percent = 100 * (value - lag(value)) / lag(value) # Percent change from previous year
  ) %>%
  ungroup()

# Calculate rank by year (higher value => higher rank)
dat <- dat %>%
  group_by(year) %>%
  mutate(rank = dense_rank(desc(value))) %>% # Rank countries by descending value
  ungroup()

# Calculate rank change (positive = moved up, negative = moved down)
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(rank_change = rank - lag(rank)) %>% # Change in rank compared to previous year
  ungroup()

# Select and reorder final columns
final_data <- dat %>%
  select(
    country,
    iso2c,
    iso3c,
    year,
    value,
    value_change,
    value_change_percent,
    rank,
    rank_change
  )

# Add labels (variable descriptions)
attr(final_data$country, "label") <- "Country name"
attr(final_data$iso2c, "label") <- "ISO 2-letter country code"
attr(final_data$iso3c, "label") <- "ISO 3-letter country code"
attr(final_data$year, "label") <- "Year"
attr(final_data$value, "label") <- "GDP per capita (current US$)"
attr(final_data$value_change, "label") <- "Year-over-Year change in value"
attr(final_data$value_change_percent, "label") <- "Year-over-Year percent change in value"
attr(final_data$rank, "label") <- "Country rank by GDP per capita (higher = richer)"
attr(final_data$rank_change, "label") <- "Change in rank from previous year"

# Print the first few rows of the final dataset
print(head(final_data, 10))