Parameterized reporting project using Eurostat, ONS, INE, and OCDE official statistics
-
This project will combine different statistical sources from several European countries (Spain, Greece, France, Germany, Italy, Greece) as well as statistics from the UK to compare social conditions of the population across different topics such as employment, migration and social determinants of health.
-
First section will provide general ggplot2 charts with customised formatting and small multiples statistics to easy comparison of metrics across several countries and once.
-
Then I will create a markdown document to show how different charts can be combined to feed a markdown report template
-
Following this markdown reports y will create several Quarto reports to display information about Immigration changes over last 10 years across different countries and social conditions such as changes in the Active and Inactive rates across countries and job market conditions (temporary contracts and unmemployment).
-
Finally I will provide an example on how to design and replicate a Parameterized report populated with the above set of indicators. This Parametrized report will allow to tweak several parameters to produce different reports for several countries based on a single set of parameters, that will be fed to the quarto report everytime it runs.
-
This project intends to be an example on how to apply RAP (Reproducible Analytical Pipelines) and DRY (Don't Repeat Yoursefl) principles, in a work environment that would need to automate any reporting.
-
For further details on how to turn this project into a pipeline plese this this other repo I created some months ago: https://github.com/Pablo-source/targets-test. Using {targets} package with several pipelines examples ready to be cloned from the repo and run them locally. Details for {Targets} pacakge from its GitHub repo: https://github.com/ropensci/targets
- A parameterized report is a report that accepts input values, called parameters, which are used to customize the report’s output.
- This will allow me to create a single template to generate multiple reports from a single script, by varying the parameter values.
- Unemployment by sex and age – annual data – Online data code: une_rt_a
- Eurostat Indicator: Unemployment by sex and age – annual data
- Eurostat reference table: une_rt_a
- Downloaded file: une_rt_a__custom_14324113_page_spreadsheet.xlsx
- URL: Unemployment by sex and age – annual data. Online data code: [une_rt_a] https://ec.europa.eu/eurostat/databrowser/view/une_rt_a/default/table?lang=en&category=labour.employ.lfsi.une
- Part-time employment and temporary contracts – annual data - Online data code:lfsi_pt_a
- Eurostat Indicator: Employed persons with temporary contract
- Eurostat reference table: [lfsi_pt_a]. Activity and employment status (EMP_TEMP)>Employed persons with temporary contract
- Downloaded file: lfsi_pt_a__custom_14828862_page_spreadsheet.xlsx
- URL: Part-time employment and temporary contracts – annual data - Online data code:[lfsi_pt_a] https://ec.europa.eu/eurostat/databrowser/view/lfsi_pt_a__custom_14828862/default/table?lang=en
- As we can see in script "05_Faceted_charts_custom_line_colour.R, we can apply custom legend text and colours
- Applied scale_colour_manual() function
- scale_colour_manual(values = c("blue", "black"),labels = c("Temporary contracts rate (%)","Unemployment rate (%)"))
- Custom legend applied in chart below:
- See script "07_Annotate_curve_draw_straight_lines.R" for details:
- Used
annotate('curve')
to include straight line annotation to specific plot value - Included
geom_richtext()
function to add annotation buble to the chart
- See script "08 Net migration figures Spain.R" for details in this project.
- Used
geom_text(aes(y = label_y, color = direction))
to include data labels to barplots. Using color to highligh positive and negative values. - Also used
mutate(direction = ifelse(net_migration <0, "negative", "positive"))
to build the flag variable used to identify color changes in the plot. - In a future Quarto document, I will explore the relationship between Immigration and Labour market conditions in some European countries and also in the UK
- Included thousands separator in ggplot():
fill = direction,label = format(net_migration, big.mark = ",")))
- Source: Statistics on Migrations and Changes of Residence (SMCR).Source: National Statistics Institute. Spanish Statistical Office. INE.
- Evolution of net external migration. 2014-2023. INE: https://www.ine.es/dyngs/Prensa/en/EMCR2023.htm

-
I will include a chart comparing net migration figures across European countries and also with the UK, Eurostat website for Net migration figures: https://ec.europa.eu/eurostat/databrowser/view/migr_netmigr/default/table?lang=en
-
Really useful and interesting online resources to create ggplot2 charts with flags to highlight changes in data:
-
Riffomonas Project – YouTube channel about R and ggplot2
-
Exploring the volatility of the S&P under Trump using the quantmod and tidyverse R paclages (CC357) https://www.youtube.com/watch?v=-UpqE1ilVuo
-
Riffomonas Project – YouTube channel about R and ggplot2
-
Using ggplot2 to demonstrate the regressive nature of Trump’s spending fill (CC364) https://www.youtube.com/watch?v=-tx7p68I0m4