Get the series from BCB
Usage
get_series(
code,
start_date = NULL,
end_date = NULL,
last = 0,
as = c("tibble", "xts", "ts", "data.frame", "text")
)
Arguments
- code
series code
- start_date
series initial date. Accepts ISO character formated date and
Date
.- end_date
series final date. Accepts ISO character formated date and
Date
.- last
last items of the series
- as
the returning type: data objects (
tibble, xts, data.frame, ts
) ortext
for raw JSONcode
argument can be obtained in the SGS system site. In this site searches can be executed in order to find out the desired series and use the series code in thecode
argument.The arguments
start_date
,end_date
andlast
are optional. If none of these arguments are set, then the entire time series is downloaded. Definestart_date
andend_date
to download a period of data and to download the lastN
registers define thelast
argument toN
a positive integer. Oncelast
is provided it overrides the argumentsstart_date
andend_date
.
Value
tibble
is the default returning class, but the argument as
can be set
to xts
, data.frame
, ts
, or text
to return these other types.
text
returns the JSON data provided by the remote API.
Examples
# download the entire series
if (FALSE) {
get_series(1)
}
# download a period of dates
if (FALSE) {
get_series(1, start_date = "2016-12-01")
}
if (FALSE) {
x <- get_series(1, start_date = "2016-12-01", end_date = "2016-12-31")
}
# downlaod the last register
if (FALSE) {
x <- get_series(1, last = 1)
}