Newer
Older
devtools::install_url("https://renkulab.io/gitlab/dscc/metadata-auto-r-library/-/archive/v002/metadata-auto-r-library-v002.tar.gz")
library(fso.metadata)
library(ggplot2)
library(tidyverse)
# All languages
codelist <- get_codelist(identifier='CL_NOGA_SECTION')
# In french
codelist_fr <- get_codelist(identifier='CL_NOGA_SECTION', language='fr')
head(codelist_fr, 3)
# All language: Level 1
nomenclature <- get_nomenclature_one_level(
nomenclature_fr <- get_nomenclature_one_level(
identifier='HCL_CH_ISCO_19_PROF',
level_number=1,
language='fr'
# French
multi_nomenclature_fr <- get_nomenclature_multiple_levels(
identifier='HCL_CH_ISCO_19_PROF',
language='fr'
)
### 4. Concrete example from Mr. van Nieuwkoop with Noga Data
load("data/pkagg.Rdata")
head(pk_agg$A88)
noga2 <- as_tibble(get_codelist(identifier='CL_NOGA_DIVISION', language='it'))
names(noga2) <- c('id', 'label', 'name')
head(noga2)
# Get the completely disaggregated production accounts
# and join them with the noga2 descriptions
a88 <- pk_agg$A88 %>%
left_join(noga2, by = c("Code" = "id"))
head(a88)
# Filter and prepare data
a88_filtered <- a88 %>%
select(-Beschreibung, -name) %>%
relocate(label, .after = Code) %>%
rename(Department = label, Year = Jahr, Component = Komponent) %>%
select(Code, Department, Component, Year, Nominal) %>%
filter( Nominal > 0) %>%
filter(!is.na(Department)) %>% # keep
filter(Code %in% c("01","02", "03")) # keep first 3 department
# Plot the intermediate consumption (CI), the value added (VA), and the
# production value (VP) for the section A (agriculture)
ggplot(a88_filtered, aes(Year, Nominal, color = Component)) +
geom_line() +
ylab("in Mio. CHF") +
facet_wrap(~Department, scales = "free")