bde_series_load | R Documentation |
The series alias is a positional code showing the location (column and/or row) of the series in the table. However, although it is unique, it is not a good candidate to be used as the series ID, as it is subject to change. If a series changes position in the table, its alias will also change.
To ensure series can still be identified, even after these changes, they
are assigned a sequential number (series_code
on this function) which
will remain unchanged throughout the series' lifetime.
Note that a single series could be used on different tables, so it can have
several aliases. If you need to search by alias it is recommended to 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
)
series_code |
a numeric (or coercible with |
series_label |
Optional. Character vector or value. Allows to specify a
custom label for the series extracted. It should have the same length than
|
out_format |
Defines if the format must be returned as a "long" dataset
or a "wide" dataset. Possible values are |
parse_dates |
Logical. If |
parse_numeric |
Logical. If |
cache_dir |
A path to a cache directory. The directory can also be set
via options with |
update_cache |
Logical. If |
verbose |
Logical |
extract_metadata |
Logical |
Load a single time-series provided by BdE.
A tibble
with a field Date
and :
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
would have two more columns,
serie_name
with the labels of each series and serie_value
with the
value of the series.
"wide"
format is more suitable for exporting to a .csv
file while
"long"
format is more suitable for producing plots with
ggplot2::ggplot()
. See also tidyr::pivot_longer()
and
tidyr::pivot_wider()
.
This function tries to coerce the columns to numbers. For some series a
warning may be displayed if the parser fails. You can override the default
behavior with parse_numeric = FALSE
bde_catalog_load()
,
bde_catalog_search()
, bde_indicators()
Other series:
bde_series_full_load()
# Metadata
bde_series_load(573234, verbose = TRUE, extract_metadata = TRUE)
# Data
bde_series_load(573234, extract_metadata = FALSE)
# Vectorized
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")
)
# Wide format
wide
# Long format
long <- bde_series_load(c(573234, 573214),
series_label = c("US/EUR", "GBP/EUR"),
out_format = "long"
)
long
# Use with ggplot
library(ggplot2)
ggplot(long, aes(Date, serie_value)) +
geom_line(aes(group = serie_name, color = serie_name)) +
scale_color_bde_d() +
theme_tidybde()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.