## Process the AROPE data 

# Load the data 
data <- read.delim("estat_tgs00107.tsv", header = TRUE, sep = "\t")

# Rename the columns
cols <- c("NUTS_ID", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023")
colnames(data) <- cols

# Transform first column to just the NUTS2 code 
data$NUTS_ID <- stringr::str_sub(data$NUTS_ID, 10)

# Gather all years 
data <- data %>% tidyr::gather(year, arope, 2:11)

# Convert : to 0
data$arope <- stringr::str_replace_all(data$arope, ":", "0")

# Convert to numeric 
data$arope <- stringr::str_replace_all(data$arope, "[^0-9.]", "")
data$arope <- as.numeric(data$arope)

# Save 
write_csv(data, "arope.csv")






