library(dplyr)
# Load EUROSTAT data of manure storage deposits
data(manure)
# Data varies at the NUTS level x indicator x year x country x NUTS code level
head(manure)
# Convert NUTS 2 codes in Germany from 2006 to 2021 version
manure %>%
filter(nchar(geo) == 4) %>%
filter(indic_ag == 'I07A_EQ_Y') %>%
filter(grepl('^DE', geo)) %>%
filter(time == 2003) %>%
select(-indic_ag, -time) %>%
# Data now only varies at the NUTS code level
nuts_classify(nuts_code = "geo") %>%
nuts_convert_version(to_version = '2021',
weight = 'pop18',
variables = c('values' = 'absolute'))
# Convert NUTS 3 codes by country x year, classifying version first
manure %>%
filter(nchar(geo) == 5) %>%
filter(indic_ag == 'I07A_EQ_Y') %>%
select(-indic_ag) %>%
# Data now varies at the year x NUTS code level
nuts_classify(nuts_code = 'geo', group_vars = c('time')) %>%
nuts_convert_version(to_version = '2021',
weight = 'pop18',
variables = c('values' = 'absolute'))
Run the code above in your browser using DataLab