##################################################
################ PREPARATION #####################
##################################################
# Windows user: Use Sys.setlocale("LC_ALL", "English_United States.utf8") in line 7.
# Clear environment and set encoding
rm(list=ls())
Sys.setlocale("LC_ALL", "en_US.UTF-8")

# Load packages required for this script
library(groundhog)
library(rjson)
source("code/misc/function_file_paths.R")
groundhog_day = fromJSON(file=path_to("groundhog_day"))
packages = c(
  "haven", "countrycode", "tibble", "plyr", "dplyr",
  "tidyr", "labelled", "sjlabelled", "showtext",
  "ggplot2", "patchwork", "ggpubr", "Hmisc", "sandwich",
  "anesrake", "curl", "readxl", "lmtest", "stargazer"
)
groundhog.library(packages, groundhog_day)

# Add fonts, start showtext
font_add_google("Roboto Condensed", "rob_con")
showtext_auto()


##################################################
################ CLEAN ###########################
##################################################
# Cleaning
source(path_to("clean_gcd"))
source(path_to("clean_world"))
source(path_to("clean_gcd_weights"))
source(path_to("std_vars"))
source(path_to("merge_world"))
source(path_to("export_dta"))

# Analysis
source(path_to("fig_2"))
source(path_to("fig_3"))
source(path_to("fig_S1"))


