Returns ECB data for a given flow and key
Usage
ecb_data(
flow,
key = NULL,
start_period = NULL,
end_period = NULL,
first_n = NULL,
last_n = NULL
)
Arguments
- flow
(
character(1)
) flow to query.- key
(
character(1)
) key to query.- start_period
(
character(1)
) start date of the data. Supported formats:YYYY for annual data (e.g., "2019")
YYYY-S[1-2] for semi-annual data (e.g., "2019-S1")
YYYY-Q[1-4] for quarterly data (e.g., "2019-Q1")
YYYY-MM for monthly data (e.g., "2019-01")
YYYY-W[01-53] for weekly data (e.g., "2019-W01")
YYYY-MM-DD for daily and business data (e.g., "2019-01-01") If
NULL
, no start date restriction is applied (data retrieved from the earliest available date). DefaultNULL
.
- end_period
(
character(1)
) end date of the data, in the same format as start_period. IfNULL
, no end date restriction is applied (data retrieved up to the most recent available date). DefaultNULL
.- first_n
(
numeric(1)
) number of observations to retrieve from the start of the series. IfNULL
, no restriction is applied. DefaultNULL
.- last_n
(
numeric(1)
) number of observations to retrieve from the end of the series. IfNULL
, no restriction is applied. DefaultNULL
.
See also
Other data:
bbk_data()
,
bbk_series()
,
snb_data()
Examples
# \donttest{
# fetch US dollar/Euro exchange rate
ecb_data("EXR", "D.USD.EUR.SP00.A")
#> date key value title
#> <Date> <char> <num> <char>
#> 1: 1999-01-04 D.USD.EUR.SP00.A 1.1789 Euro/US dollar
#> 2: 1999-01-05 D.USD.EUR.SP00.A 1.1790 Euro/US dollar
#> 3: 1999-01-06 D.USD.EUR.SP00.A 1.1743 Euro/US dollar
#> 4: 1999-01-07 D.USD.EUR.SP00.A 1.1632 Euro/US dollar
#> 5: 1999-01-08 D.USD.EUR.SP00.A 1.1659 Euro/US dollar
#> ---
#> 6711: 2024-12-16 D.USD.EUR.SP00.A 1.0498 Euro/US dollar
#> 6712: 2024-12-17 D.USD.EUR.SP00.A 1.0497 Euro/US dollar
#> 6713: 2024-12-18 D.USD.EUR.SP00.A 1.0496 Euro/US dollar
#> 6714: 2024-12-19 D.USD.EUR.SP00.A 1.0395 Euro/US dollar
#> 6715: 2024-12-20 D.USD.EUR.SP00.A 1.0390 Euro/US dollar
#> description freq
#> <char> <char>
#> 1: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 2: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 3: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 4: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 5: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> ---
#> 6711: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 6712: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 6713: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 6714: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 6715: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> currency currency_denom exr_type exr_suffix collection unit_mult
#> <char> <char> <char> <char> <char> <char>
#> 1: USD EUR SP00 A A 0
#> 2: USD EUR SP00 A A 0
#> 3: USD EUR SP00 A A 0
#> 4: USD EUR SP00 A A 0
#> 5: USD EUR SP00 A A 0
#> ---
#> 6711: USD EUR SP00 A A 0
#> 6712: USD EUR SP00 A A 0
#> 6713: USD EUR SP00 A A 0
#> 6714: USD EUR SP00 A A 0
#> 6715: USD EUR SP00 A A 0
#> source_agency time_format unit decimals
#> <char> <char> <char> <char>
#> 1: 4F0 P1D USD 4
#> 2: 4F0 P1D USD 4
#> 3: 4F0 P1D USD 4
#> 4: 4F0 P1D USD 4
#> 5: 4F0 P1D USD 4
#> ---
#> 6711: 4F0 P1D USD 4
#> 6712: 4F0 P1D USD 4
#> 6713: 4F0 P1D USD 4
#> 6714: 4F0 P1D USD 4
#> 6715: 4F0 P1D USD 4
# fetch data for multiple keys
ecb_data("EXR", c("D.USD", "JPY.EUR.SP00.A"))
#> date key value title
#> <Date> <char> <num> <char>
#> 1: 1999-01-04 D.JPY.EUR.SP00.A 133.7300 Euro/Japanese yen
#> 2: 1999-01-05 D.JPY.EUR.SP00.A 130.9600 Euro/Japanese yen
#> 3: 1999-01-06 D.JPY.EUR.SP00.A 131.4200 Euro/Japanese yen
#> 4: 1999-01-07 D.JPY.EUR.SP00.A 129.4300 Euro/Japanese yen
#> 5: 1999-01-08 D.JPY.EUR.SP00.A 130.0900 Euro/Japanese yen
#> ---
#> 13426: 2024-12-16 D.USD.EUR.SP00.A 1.0498 Euro/US dollar
#> 13427: 2024-12-17 D.USD.EUR.SP00.A 1.0497 Euro/US dollar
#> 13428: 2024-12-18 D.USD.EUR.SP00.A 1.0496 Euro/US dollar
#> 13429: 2024-12-19 D.USD.EUR.SP00.A 1.0395 Euro/US dollar
#> 13430: 2024-12-20 D.USD.EUR.SP00.A 1.0390 Euro/US dollar
#> description freq
#> <char> <char>
#> 1: ECB reference exchange rate, Euro/Japanese yen, 2:15 pm (C.E.T.) daily
#> 2: ECB reference exchange rate, Euro/Japanese yen, 2:15 pm (C.E.T.) daily
#> 3: ECB reference exchange rate, Euro/Japanese yen, 2:15 pm (C.E.T.) daily
#> 4: ECB reference exchange rate, Euro/Japanese yen, 2:15 pm (C.E.T.) daily
#> 5: ECB reference exchange rate, Euro/Japanese yen, 2:15 pm (C.E.T.) daily
#> ---
#> 13426: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 13427: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 13428: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 13429: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> 13430: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.) daily
#> currency currency_denom exr_type exr_suffix decimals unit unit_mult
#> <char> <char> <char> <char> <char> <char> <char>
#> 1: JPY EUR SP00 A 2 JPY 0
#> 2: JPY EUR SP00 A 2 JPY 0
#> 3: JPY EUR SP00 A 2 JPY 0
#> 4: JPY EUR SP00 A 2 JPY 0
#> 5: JPY EUR SP00 A 2 JPY 0
#> ---
#> 13426: USD EUR SP00 A 4 USD 0
#> 13427: USD EUR SP00 A 4 USD 0
#> 13428: USD EUR SP00 A 4 USD 0
#> 13429: USD EUR SP00 A 4 USD 0
#> 13430: USD EUR SP00 A 4 USD 0
#> collection time_format source_agency
#> <char> <char> <char>
#> 1: A P1D 4F0
#> 2: A P1D 4F0
#> 3: A P1D 4F0
#> 4: A P1D 4F0
#> 5: A P1D 4F0
#> ---
#> 13426: A P1D 4F0
#> 13427: A P1D 4F0
#> 13428: A P1D 4F0
#> 13429: A P1D 4F0
#> 13430: A P1D 4F0
# }