| bde_series | R Documentation |
These functions load BdE time series from the bulk CSV files published by Banco de España.
bde_series_load() extracts one or more series by their stable sequential
number. bde_series_full_load() loads a complete bulk CSV file and returns
all series included in that file.
See vignette("csv_manual", package = "tidyBdE") for details.
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_full_load(
series_csv,
parse_dates = TRUE,
parse_numeric = TRUE,
cache_dir = NULL,
update_cache = FALSE,
verbose = FALSE,
extract_metadata = FALSE
)
series_code |
A numeric vector of stable BdE sequential numbers, or
values coercible with |
series_label |
An optional character vector of labels to assign to the extracted series. |
out_format |
The output format, 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 |
series_csv |
A bulk CSV file name for a series, as defined in the field
|
bde_series_load() returns 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 contains the label of each series; serie_value contains the
corresponding value.
"wide" format is more suitable for exporting to a CSV file;
"long" format is more suitable for creating plots with
ggplot2::ggplot(). See also tidyr::pivot_longer() and
tidyr::pivot_wider().
bde_series_full_load() returns a tibble with a Date
column and the aliases of the time series columns as described in catalog
metadata. See bde_catalog_load() and
vignette("csv_manual", package = "tidyBdE") for details.
A series alias is a positional code that identifies the location, column or row of a series in a table. An alias is unique within its context but is not stable because it may change when a series moves.
A single time series may appear in different tables, so it can have several
aliases. Use bde_series_full_load() when you need to work with aliases or
load a complete file.
The series alias is also used in full CSV files. 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.
BdE identifies each series with a stable sequential number
(Numero_secuencial) in bulk CSV files and an API series code
(Nombre_de_la_serie) in the Statistics web service.
bde_series_load() accepts stable sequential numbers in series_code.
bde_series_api_latest() and bde_series_api_load() use the same argument
for API series codes. Use bde_catalog_load() or bde_catalog_search() to
find both identifiers.
These functions attempt to parse columns as double values. For some time
series, a warning may be displayed if parsing fails. Set
parse_numeric = FALSE to disable numeric parsing.
Banco de España time series bulk data download.
bde_catalog_load() and bde_catalog_search() help find stable sequential
numbers.
Indicator wrappers retrieve commonly used Spanish macroeconomic series.
Time series functions:
bde_series_api
# 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 for a complete bulk CSV file.
bde_series_full_load("TI_1_1.csv", extract_metadata = TRUE)
# Load a complete bulk CSV file.
bde_series_full_load("TI_1_1.csv")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.