Commit 05206233 authored by Pauline Maury Laribière's avatar Pauline Maury Laribière
Browse files

demo ready

parent 5ecae477
Pipeline #326978 passed with stage
in 12 seconds
# When the package will be finished, install via CRAN
# install.packages("fso.metadata")
# Currently use: ### Preparation ###
devtools::install_url("https://renkulab.io/gitlab/dscc/metadata-auto-r-library/-/archive/v002/metadata-auto-r-library-v002.tar.gz") 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(fso.metadata)
library(ggplot2)
library(tidyverse)
### 1. Get a codelist ###
## Get a codelist
# All languages # All languages
codelist <- get_codelist(identifier='CL_NOGA_SECTION') codelist <- get_codelist(identifier='CL_NOGA_SECTION')
names(codelist) head(codelist, 3)
head(codelist)
# In french # In french
codelist <- get_codelist(identifier='CL_NOGA_SECTION', language='fr') codelist_fr <- get_codelist(identifier='CL_NOGA_SECTION', language='fr')
names(codelist) head(codelist_fr, 3)
head(codelist$label.fr)
head(codelist$id)
## Get a nomenclature of one level ### 2. Get a nomenclature of one level ###
# All language: Level 1 # All language: Level 1
nomenclature <- get_nomenclature_one_level( nomenclature <- get_nomenclature_one_level(
identifier='HCL_CH_ISCO_19_PROF', level_number=2 identifier='HCL_CH_ISCO_19_PROF',
level_number=2
) )
names(nomenclature) head(nomenclature, 3)
head(nomenclature, 5)
# French: Level 2 # French: Level 2
nomenclature_fr <- get_nomenclature_one_level( nomenclature_fr <- get_nomenclature_one_level(
identifier='HCL_CH_ISCO_19_PROF', level_number=1, language='fr' identifier='HCL_CH_ISCO_19_PROF',
level_number=1,
language='fr'
) )
names(nomenclature_fr)
head(nomenclature_fr, 5) head(nomenclature_fr, 5)
nomenclature_de <- get_nomenclature_one_level(
identifier='HCL_CH_ISCO_19_PROF', level_number=1, language='de'
)
names(nomenclature_de)
head(nomenclature_de, 5)
## Get a nomenclature of multiple levels
### 3. Get a nomenclature of multiple levels ###
# French # French
multi_nomenclature_fr <- get_nomenclature_multiple_levels( multi_nomenclature_fr <- get_nomenclature_multiple_levels(
identifier='HCL_CH_ISCO_19_PROF', identifier='HCL_CH_ISCO_19_PROF',
level_from=1, level_from=1,
level_to=5, level_to=6,
language='fr' language='fr'
) )
head(multi_nomenclature_fr, 5) head(multi_nomenclature_fr, 10)
# German
multi_nomenclature_de <- get_nomenclature_multiple_levels(
identifier='HCL_CH_ISCO_19_PROF',
level_from=2,
level_to=3,
language='de'
)
head(multi_nomenclature_de, 5)
### 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")
...@@ -2,6 +2,7 @@ install.packages(c( ...@@ -2,6 +2,7 @@ install.packages(c(
"devtools", "roxygen2", "document", "styler", "httr", "jsonlite", "glue", "devtools", "roxygen2", "document", "styler", "httr", "jsonlite", "glue",
"pkgdown" "pkgdown"
)) ))
install.packages("ggplot")
devtools::install_github("opensdmx/rsdmx") devtools::install_github("opensdmx/rsdmx")
## Load and test library ## Load and test library
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment