| Title: | Retrieve Time Series Data from 'Banco de España' |
|---|---|
| Description: | Tools for retrieving time series data from 'Banco de España' ('BdE') as 'tibble' objects. 'Banco de España' is the national central bank and, within the framework of the Single Supervisory Mechanism ('SSM'), the supervisor of the Spanish banking system alongside the European Central Bank. This package is not sponsored, endorsed or administered by 'Banco de España'. |
| Authors: | Diego H. Herrero [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-8457-4658>) |
| Maintainer: | Diego H. Herrero <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.6.1.9000 |
| Built: | 2026-06-03 13:20:10 UTC |
| Source: | https://github.com/rOpenSpain/tidyBdE |
Load BdE time series catalog metadata.
bde_catalog_load( catalog = c("ALL", "BE", "SI", "TC", "TI", "PB"), parse_dates = TRUE, cache_dir = NULL, update_cache = FALSE, verbose = FALSE )bde_catalog_load( catalog = c("ALL", "BE", "SI", "TC", "TI", "PB"), parse_dates = TRUE, cache_dir = NULL, update_cache = FALSE, verbose = FALSE )
catalog |
A single catalog identifier to load, or |
parse_dates |
Logical. If |
cache_dir |
Path to a cache directory. The directory can also be set
with |
update_cache |
Logical. If |
verbose |
Logical. If |
Accepted values for catalog are:
| CODE | PUBLICATION | UPDATE FREQUENCY | FREQUENCY |
"BE" |
Statistical Bulletin | Daily | Monthly |
"SI" |
Summary Indicators | Daily | Daily |
"TC" |
Exchange Rates | Daily | Daily |
"TI" |
Interest Rates | Daily | Daily |
"PB" |
Bank Lending Survey | Quarterly | Quarterly |
Use "ALL" as a shorthand for loading all catalogs at once.
If the requested catalog is not cached, this function calls
bde_catalog_update().
A tibble with the requested catalog metadata.
Time series bulk data download.
Other catalog:
bde_catalog_search(),
bde_catalog_update()
bde_catalog_load("TI", verbose = TRUE)bde_catalog_load("TI", verbose = TRUE)
Search BdE time series catalog metadata for keywords.
bde_catalog_search(pattern, ...)bde_catalog_search(pattern, ...)
pattern |
|
... |
Arguments passed on to
|
Note: BdE metadata is currently available in Spanish only. Therefore, search terms must be in Spanish to retrieve results.
This function uses base::grep() to find matches in the catalogs. You can
pass regular expressions to broaden the search.
A tibble object with the results of the query.
bde_catalog_load(), base::regex
Other catalog:
bde_catalog_load(),
bde_catalog_update()
# Simple search. Search terms must be in Spanish. # PIB [es] == GDP [en]. bde_catalog_search("PIB") # Search with a single complex condition. bde_catalog_search("Francia(.*)PIB") # Search with multiple complex conditions. bde_catalog_search("Francia(.*)PIB|Italia(.*)PIB|Alemania(.*)PIB")# Simple search. Search terms must be in Spanish. # PIB [es] == GDP [en]. bde_catalog_search("PIB") # Search with a single complex condition. bde_catalog_search("Francia(.*)PIB") # Search with multiple complex conditions. bde_catalog_search("Francia(.*)PIB|Italia(.*)PIB|Alemania(.*)PIB")
Update BdE time series catalog files.
bde_catalog_update( catalog = c("ALL", "BE", "SI", "TC", "TI", "PB"), cache_dir = NULL, verbose = FALSE )bde_catalog_update( catalog = c("ALL", "BE", "SI", "TC", "TI", "PB"), cache_dir = NULL, verbose = FALSE )
catalog |
A single catalog identifier to update, or |
cache_dir |
Path to a cache directory. The directory can also be set
with |
verbose |
Logical. If |
Accepted values for catalog are:
| CODE | PUBLICATION | UPDATE FREQUENCY | FREQUENCY |
"BE" |
Statistical Bulletin | Daily | Monthly |
"SI" |
Summary Indicators | Daily | Daily |
"TC" |
Exchange Rates | Daily | Daily |
"TI" |
Interest Rates | Daily | Daily |
"PB" |
Bank Lending Survey | Quarterly | Quarterly |
Use "ALL" as a shorthand for updating all catalogs at once.
An invisible list of download results.
Time series bulk data download.
Other catalog:
bde_catalog_load(),
bde_catalog_search()
bde_catalog_update("TI", verbose = TRUE)bde_catalog_update("TI", verbose = TRUE)
Minimal metadata for the selected Spanish macroeconomic indicators included
in the convenience functions of tidyBdE (see bde_indicators).
Full metadata can be accessed with bde_catalog_load().
A tibble of 9 rows and 7 columns with the following fields:
Function name. See bde_indicators.
Series code. See bde_series_load().
Description of the series in Spanish.
Starting date of the indicator.
Most recent date available.
Data source.
| tidyBdE_fun | Numero_secuencial | Descripcion_de_la_serie | Frecuencia_de_la_serie | Fecha_de_la_primera_observacion | Fecha_de_la_ultima_observacion | Fuente |
| bde_ind_cpi_var | 1489713 | Estadísticas Generales. IPCA. Base 2015. Índice general. Tasa interanual. España | MENSUAL | 1993-01-01 | 2025-12-01 | Eurostat |
| bde_ind_euribor_12m_daily | 905842 | Tipo de interés. UEM. Mercado monetario. Euríbor. A 12 meses | LABORABLE | 2000-01-03 | 2026-02-13 | REFINITIV |
| bde_ind_euribor_12m_monthly | 587853 | Tipo de interés. UEM. Mercado monetario. Euríbor. A 12 meses | MENSUAL | 1999-01-01 | 2026-01-01 | The European Money Market Institute (EMMI) |
| bde_ind_gdp_quarterly | 4663160 | Estadísticas Generales. Cuentas Nacionales. SEC2010. Año base 2020. Precios corrientes. Producto interior bruto. Economía en su conjunto (Total de la economía) (Saldo). Datos corregidos de efectos estacionales y de calendario. TRIMESTRAL | TRIMESTRAL | 1995-03-01 | 2025-12-01 | Instituto Nacional de Estadistica |
| bde_ind_gdp_var | 4663788 | Estadísticas Generales. CNTR. Base 2020. PIB. Precios constantes. Datos CVEC. Tasa interanual. España | TRIMESTRAL | 1996-03-01 | 2025-12-01 | Eurostat |
| bde_ind_ibex_daily | 821340 | Cotización y contratación. Acciones. Sociedad de Bolsas y Sociedad Rectora de la Bolsa de Madrid. Índice cotización. Indice IBEX 35 | LABORABLE | 1999-01-04 | 2026-02-13 | Bolsa de Madrid y Comisión Nacional del Mercado de Valores |
| bde_ind_ibex_monthly | 254433 | Cotización y contratación. Acciones. Sociedad de Bolsas y Sociedad Rectora de la Bolsa de Madrid. Índice cotización. Indice IBEX 35 | MENSUAL | 1987-01-01 | 2025-12-01 | SOCIEDAD RECTORA DE LA BOLSA DE MADRID |
| bde_ind_population | 4637737 | Estadísticas generales. INE. EPA. Base 2021. Total Nacional. Ambos sexos. Todas las edades. Personas. Trimestral | TRIMESTRAL | 2002-03-01 | 2025-09-01 | Instituto Nacional de Estadística |
| bde_ind_unemployment_rate | 4635980 | Estadísticas Generales. EPA. Base 2021. Total Nacional. Tasa de paro de la población. Ambos sexos. 16 y más años | TRIMESTRAL | 2002-03-01 | 2025-12-01 | Instituto Nacional de Estadística |
Other indicators:
bde_indicators
data("bde_ind_db") bde_ind_dbdata("bde_ind_db") bde_ind_db
Convenience functions for downloading selected Spanish macroeconomic indicators. Metadata is available in bde_ind_db.
bde_ind_gdp_var(series_label = "GDP_YoY", ...) bde_ind_unemployment_rate(series_label = "Unemployment_Rate", ...) bde_ind_euribor_12m_monthly(series_label = "Euribor_12M_Monthly", ...) bde_ind_euribor_12m_daily(series_label = "Euribor_12M_Daily", ...) bde_ind_cpi_var(series_label = "Consumer_price_index_YoY", ...) bde_ind_ibex_monthly(series_label = "IBEX_index_month", ...) bde_ind_ibex_daily(series_label = "IBEX_index_day", ...) bde_ind_gdp_quarterly(series_label = "GDP_quarterly_value", ...) bde_ind_population(series_label = "Population_Spain", ...)bde_ind_gdp_var(series_label = "GDP_YoY", ...) bde_ind_unemployment_rate(series_label = "Unemployment_Rate", ...) bde_ind_euribor_12m_monthly(series_label = "Euribor_12M_Monthly", ...) bde_ind_euribor_12m_daily(series_label = "Euribor_12M_Daily", ...) bde_ind_cpi_var(series_label = "Consumer_price_index_YoY", ...) bde_ind_ibex_monthly(series_label = "IBEX_index_month", ...) bde_ind_ibex_daily(series_label = "IBEX_index_day", ...) bde_ind_gdp_quarterly(series_label = "GDP_quarterly_value", ...) bde_ind_population(series_label = "Population_Spain", ...)
series_label |
Optional character string or vector of labels to assign to the extracted series. |
... |
Arguments passed on to
|
These functions are convenient wrappers around bde_series_load() for
specific series. Use verbose = TRUE, extract_metadata = TRUE to inspect the
metadata and source.
A tibble with the required series.
bde_series_load(), bde_catalog_search()
Other indicators:
bde_ind_db
bde_ind_gdp_var()bde_ind_gdp_var()
Parse strings representing dates with as.Date(). This function is tailored
to date formats used in this package and may fail with other datasets. See
Examples for formats that are supported.
| FREQUENCY | FORMAT | EXAMPLES |
| Daily / Business day | DD MMMMYYYY | 02 FEB2019 |
| Monthly | MMM YYYY | MAR 2020 |
| Quarterly | MMM YYYY, where MMM is the first or the last month of the quarter, depending on the value of its variable OBSERVED. | For the first quarter of 2020: ENE 2020, MAR 2020 |
| Half-yearly | MMM YYYY, where MMM is the first or the last month of the half-year period, depending on the value of its variable OBSERVED. | For the first half of 2020: ENE 2020, JUN 2020 |
| Annual | YYYY | 2020 |
bde_parse_dates(dates_to_parse)bde_parse_dates(dates_to_parse)
dates_to_parse |
Character vector of dates to parse. |
A vector of Date values.
# Supported formats. would_parse <- c( "02 FEB2019", "15 ABR 1890", "MAR 2020", "ENE2020", "2020", "12-1993", "01-02-2014", "01/02/1990" ) parsed_ok <- bde_parse_dates(would_parse) class(parsed_ok) tibble::tibble(raw = would_parse, parsed = parsed_ok) # Unsupported formats. wont_parse <- c("JAN2001", "2010-01-12", "01 APR 2017", "01/31/1990") parsed_fail <- bde_parse_dates(wont_parse) class(parsed_fail) tibble::tibble(raw = wont_parse, parsed = parsed_fail)# Supported formats. would_parse <- c( "02 FEB2019", "15 ABR 1890", "MAR 2020", "ENE2020", "2020", "12-1993", "01-02-2014", "01/02/1990" ) parsed_ok <- bde_parse_dates(would_parse) class(parsed_ok) tibble::tibble(raw = would_parse, parsed = parsed_ok) # Unsupported formats. wont_parse <- c("JAN2001", "2010-01-12", "01 APR 2017", "01/31/1990") parsed_fail <- bde_parse_dates(wont_parse) class(parsed_fail) tibble::tibble(raw = wont_parse, parsed = parsed_fail)
Load a full BdE time series file.
The series name is a positional code showing the location of the table. For example, table be_6_1 represents Table 1, Chapter 6 of the Statistical Bulletin ("BE"). Although it is unique, it is subject to change, for example when a new table is inserted before it.
For that reason, bde_series_load() is more suitable for extracting
specific time series.
bde_series_full_load( series_csv, parse_dates = TRUE, parse_numeric = TRUE, cache_dir = NULL, update_cache = FALSE, verbose = FALSE, extract_metadata = FALSE )bde_series_full_load( series_csv, parse_dates = TRUE, parse_numeric = TRUE, cache_dir = NULL, update_cache = FALSE, verbose = FALSE, extract_metadata = FALSE )
series_csv |
CSV file name for a series, as defined in the field
|
parse_dates |
Logical. If |
parse_numeric |
Logical. If |
cache_dir |
Path to a cache directory. The directory can also be set
with |
update_cache |
Logical. If |
verbose |
Logical. If |
extract_metadata |
Logical. If |
A tibble with a Date field and the aliases of
the time series fields as described in the catalogs. See
bde_catalog_load().
This function tries to coerce the columns to numbers. For some time series,
a warning may be displayed if the parser fails. You can override the default
behavior with parse_numeric = FALSE.
Other series:
bde_series_load()
# Show metadata. bde_series_full_load("TI_1_1.csv", extract_metadata = TRUE) # Load data. bde_series_full_load("TI_1_1.csv")# Show metadata. bde_series_full_load("TI_1_1.csv", extract_metadata = TRUE) # Load data. bde_series_full_load("TI_1_1.csv")
Load a single BdE time series.
The series alias is a positional code showing the location (column and/or row) of the series in the table. Although it is unique, it is not stable enough to identify a time series because it may change when the series moves.
To ensure series can still be identified after these changes, they are
assigned a sequential number, referred to as series_code in this function.
A single time series may appear in different tables, so it can have several
aliases. If you need to search by alias, use bde_series_full_load().
bde_series_load( series_code, series_label = NULL, out_format = "wide", parse_dates = TRUE, parse_numeric = TRUE, cache_dir = NULL, update_cache = FALSE, verbose = FALSE, extract_metadata = FALSE )bde_series_load( series_code, series_label = NULL, out_format = "wide", parse_dates = TRUE, parse_numeric = TRUE, cache_dir = NULL, update_cache = FALSE, verbose = FALSE, extract_metadata = FALSE )
series_code |
Numeric value, value coercible with |
series_label |
Optional character string or vector of labels to assign to the extracted series. |
out_format |
The format to return, either |
parse_dates |
Logical. If |
parse_numeric |
Logical. If |
cache_dir |
Path to a cache directory. The directory can also be set
with |
update_cache |
Logical. If |
verbose |
Logical. If |
extract_metadata |
Logical. If |
A tibble with a Date column:
With out_format = "wide", each series is presented in a separate column
with the name defined by series_label.
With out_format = "long", the tibble has two additional columns:
serie_name, with the label of each series, and serie_value, with the
corresponding value.
"wide" format is more suitable for exporting to a .csv file, while
"long" format is more suitable for creating plots using
ggplot2::ggplot(). See also tidyr::pivot_longer() and
tidyr::pivot_wider().
This function attempts to coerce the columns to numbers. For some time series, a warning may be displayed if the parsing fails.
bde_catalog_load(),
bde_catalog_search(), bde_indicators()
Other series:
bde_series_full_load()
# Show metadata. bde_series_load(573234, verbose = TRUE, extract_metadata = TRUE) # Load data. bde_series_load(573234, extract_metadata = FALSE) # Load multiple series. bde_series_load(c(573234, 573214), series_label = c("US/EUR", "GBP/EUR"), extract_metadata = TRUE ) wide <- bde_series_load(c(573234, 573214), series_label = c("US/EUR", "GBP/EUR") ) # Show wide output. wide # Show long output. long <- bde_series_load(c(573234, 573214), series_label = c("US/EUR", "GBP/EUR"), out_format = "long" ) long # Use with `ggplot2`. library(ggplot2) ggplot(long, aes(Date, serie_value)) + geom_line(aes(group = serie_name, color = serie_name)) + scale_color_bde_d() + theme_tidybde()# Show metadata. bde_series_load(573234, verbose = TRUE, extract_metadata = TRUE) # Load data. bde_series_load(573234, extract_metadata = FALSE) # Load multiple series. bde_series_load(c(573234, 573214), series_label = c("US/EUR", "GBP/EUR"), extract_metadata = TRUE ) wide <- bde_series_load(c(573234, 573214), series_label = c("US/EUR", "GBP/EUR") ) # Show wide output. wide # Show long output. long <- bde_series_load(c(573234, 573214), series_label = c("US/EUR", "GBP/EUR"), out_format = "long" ) long # Use with `ggplot2`. library(ggplot2) ggplot(long, aes(Date, serie_value)) + geom_line(aes(group = serie_name, color = serie_name)) + scale_color_bde_d() + theme_tidybde()
Manually defined palettes based on BdE publications. Each palette contains at most six colors.
bde_tidy_palettes( n = 6, palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE )bde_tidy_palettes( n = 6, palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE )
n |
The number of colors ( |
palette |
A valid palette name. |
alpha |
Alpha transparency level in the range |
rev |
Logical indicating whether to reverse the color order. |
A character vector of hex color codes.
Other bde_plot:
scales_bde,
theme_tidybde()
# Show the BdE vivid palette. scales::show_col(bde_tidy_palettes(palette = "bde_vivid_pal"), labels = FALSE ) # Show the BdE rose palette. scales::show_col(bde_tidy_palettes(palette = "bde_rose_pal"), labels = FALSE ) # Show the BdE qualitative palette. scales::show_col(bde_tidy_palettes(palette = "bde_qual_pal"), labels = FALSE )# Show the BdE vivid palette. scales::show_col(bde_tidy_palettes(palette = "bde_vivid_pal"), labels = FALSE ) # Show the BdE rose palette. scales::show_col(bde_tidy_palettes(palette = "bde_rose_pal"), labels = FALSE ) # Show the BdE qualitative palette. scales::show_col(bde_tidy_palettes(palette = "bde_qual_pal"), labels = FALSE )
Color scales for the ggplot2 package. Discrete scales are
named scale_*_bde_d, while continuous palettes are named scale_*_bde_c.
scale_color_bde_d( palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, ... ) scale_fill_bde_d( palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, ... ) scale_color_bde_c( palette = c("bde_rose_pal", "bde_vivid_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, guide = "colorbar", ... ) scale_fill_bde_c( palette = c("bde_rose_pal", "bde_vivid_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, guide = "colorbar", ... )scale_color_bde_d( palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, ... ) scale_fill_bde_d( palette = c("bde_vivid_pal", "bde_rose_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, ... ) scale_color_bde_c( palette = c("bde_rose_pal", "bde_vivid_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, guide = "colorbar", ... ) scale_fill_bde_c( palette = c("bde_rose_pal", "bde_vivid_pal", "bde_qual_pal"), alpha = NULL, rev = FALSE, guide = "colorbar", ... )
palette |
BdE palette to apply. See |
alpha |
Alpha transparency level in the range |
rev |
Logical indicating whether to reverse the color order. |
... |
Additional arguments passed to |
guide |
A function used to create a guide or its name. See
|
A ggplot2 scale object.
ggplot2::discrete_scale(), ggplot2::continuous_scale()
Other bde_plot:
bde_tidy_palettes(),
theme_tidybde()
library(ggplot2) set.seed(596) txsamp <- subset( txhousing, city %in% c( "Houston", "Fort Worth", "San Antonio", "Dallas", "Austin" ) ) ggplot(txsamp, aes(x = sales, y = median)) + geom_point(aes(colour = city)) + scale_color_bde_d() + theme_minimal() ggplot(txsamp, aes(x = sales, y = median)) + geom_point(aes(colour = city)) + scale_color_bde_d("bde_qual_pal") + theme_minimal()library(ggplot2) set.seed(596) txsamp <- subset( txhousing, city %in% c( "Houston", "Fort Worth", "San Antonio", "Dallas", "Austin" ) ) ggplot(txsamp, aes(x = sales, y = median)) + geom_point(aes(colour = city)) + scale_color_bde_d() + theme_minimal() ggplot(txsamp, aes(x = sales, y = median)) + geom_point(aes(colour = city)) + scale_color_bde_d("bde_qual_pal") + theme_minimal()
Custom ggplot2 theme based on BdE publications.
theme_tidybde(...)theme_tidybde(...)
... |
Arguments passed on to
|
This theme is based on ggplot2::theme_classic().
A ggplot2 theme object.
Other bde_plot:
bde_tidy_palettes(),
scales_bde
library(ggplot2) library(dplyr) library(tidyr) series_TC <- bde_series_full_load("TC_1_1.csv") # Plot if the download succeeds. if (nrow(series_TC) > 0) { series_TC <- series_TC[c(1, 2)] series_TC_pivot <- series_TC |> filter( Date >= "2020-01-01" & Date <= "2020-12-31", !is.na(series_TC[[2]]) ) names(series_TC_pivot) <- c("x", "y") ggplot(series_TC_pivot, aes(x = x, y = y)) + geom_line(linewidth = 0.8, color = bde_tidy_palettes(n = 1)) + labs( title = "Title", subtitle = "Some metric", caption = "Bank of Spain" ) + theme_tidybde() }library(ggplot2) library(dplyr) library(tidyr) series_TC <- bde_series_full_load("TC_1_1.csv") # Plot if the download succeeds. if (nrow(series_TC) > 0) { series_TC <- series_TC[c(1, 2)] series_TC_pivot <- series_TC |> filter( Date >= "2020-01-01" & Date <= "2020-12-31", !is.na(series_TC[[2]]) ) names(series_TC_pivot) <- c("x", "y") ggplot(series_TC_pivot, aes(x = x, y = y)) + geom_line(linewidth = 0.8, color = bde_tidy_palettes(n = 1)) + labs( title = "Title", subtitle = "Some metric", caption = "Bank of Spain" ) + theme_tidybde() }