bde_series_load: Load a single BdE time series

View source: R/series.R

bde_series_loadR Documentation

Load a single BdE time series

Description

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 use as the series ID 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.

Note that a single series may appear in different tables, so it can have several aliases. If you need to search by alias, use bde_series_full_load().

Usage

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
)

Arguments

series_code

A numeric value, or one coercible with base::as.double(), or a vector of time series codes, as defined in the field ⁠Número secuencial⁠ of the corresponding series. See bde_catalog_load().

series_label

Optional character string or vector of labels to assign to the extracted series.

out_format

The format to return, either "wide" or "long". See Value for details and the Examples section.

parse_dates

Logical. If TRUE, date columns are parsed with bde_parse_dates().

parse_numeric

Logical. If TRUE, the columns are parsed to double (numeric) values. See Note.

cache_dir

A path to a cache directory. The directory can also be set with options using options(bde_cache_dir = "path/to/dir").

update_cache

Logical. If TRUE, the requested file is refreshed in cache_dir.

verbose

Logical. If TRUE, display information useful for debugging.

extract_metadata

Logical. If TRUE, the output is the metadata of the requested series.

Details

Load a single BdE time series.

Value

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().

Note

This function attempts to coerce the columns to numbers. For some series, a warning may be displayed if the parsing fails.

See Also

bde_catalog_load(), bde_catalog_search(), bde_indicators()

Other series: bde_series_full_load()

Examples



# 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()



tidyBdE documentation built on May 21, 2026, 5:07 p.m.