Explore all the economic data from different providers (national and international statistical institutes, central banks, etc.), for free, following the link db.nomics.world
(N.B.: in the examples, data have already been retrieved on april 6th 2020).
ids
First, let’s assume that we know which series we want to download. A series identifier (ids
) is defined by three values, formatted like this: provider_code
/dataset_code
/series_code
.
library(data.table)
library(rdbnomics)
df <- rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN")
df <- df[!is.na(value)]
In such data.table
, you will always find at least ten columns:
provider_code
dataset_code
dataset_name
series_code
series_name
original_period
(character string)period
(date of the first day of original_period
)original_value
(character string)value
@frequency
(harmonized frequency generated by DBnomics)The other columns depend on the provider and on the dataset. They always come in pairs (for the code and the name). In the data.frame df
, you have:
unit
(code) and Unit
(name)geo
(code) and Country
(name)freq
(code) and Frequency
(name)## provider_code dataset_code dataset_name series_code
## 1: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 2: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 3: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 4: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 5: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 6: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## series_name original_period period original_value value
## 1: Annually – (Perc... 1998 1998-01-01 10.4 10.4
## 2: Annually – (Perc... 1999 1999-01-01 9.7 9.7
## 3: Annually – (Perc... 2000 2000-01-01 8.9 8.9
## 4: Annually – (Perc... 2001 2001-01-01 8.3 8.3
## 5: Annually – (Perc... 2002 2002-01-01 8.6 8.6
## 6: Annually – (Perc... 2003 2003-01-01 9.1 9.1
## @frequency unit Unit geo Country freq
## 1: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## 2: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## 3: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## 4: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## 5: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## 6: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## Frequency indexed_at
## 1: Annually 2019-11-08 16:33:50
## 2: Annually 2019-11-08 16:33:50
## 3: Annually 2019-11-08 16:33:50
## 4: Annually 2019-11-08 16:33:50
## 5: Annually 2019-11-08 16:33:50
## 6: Annually 2019-11-08 16:33:50
In the event that you only use the argument ids
, you can drop it and run:
df <- rdb("AMECO/ZUTN/EA19.1.0.0.0.ZUTN")
df <- rdb(ids = c("AMECO/ZUTN/EA19.1.0.0.0.ZUTN", "AMECO/ZUTN/DNK.1.0.0.0.ZUTN"))
df <- df[!is.na(value)]
## provider_code dataset_code dataset_name series_code
## 1: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 2: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 3: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 4: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 5: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 6: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## series_name original_period period original_value value
## 1: Annually – (Perc... 1960 1960-01-01 2 2.0
## 2: Annually – (Perc... 1961 1961-01-01 1.6 1.6
## 3: Annually – (Perc... 1962 1962-01-01 1.4 1.4
## 4: Annually – (Perc... 1963 1963-01-01 2 2.0
## 5: Annually – (Perc... 1964 1964-01-01 1.2 1.2
## 6: Annually – (Perc... 1965 1965-01-01 0.9 0.9
## @frequency unit Unit geo Country freq
## 1: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 2: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 3: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 4: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 5: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 6: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## Frequency indexed_at
## 1: Annually 2019-11-08 16:33:50
## 2: Annually 2019-11-08 16:33:50
## 3: Annually 2019-11-08 16:33:50
## 4: Annually 2019-11-08 16:33:50
## 5: Annually 2019-11-08 16:33:50
## 6: Annually 2019-11-08 16:33:50
df <- rdb(ids = c("AMECO/ZUTN/EA19.1.0.0.0.ZUTN", "Eurostat/une_rt_q/Q.SA.Y15-24.PC_ACT.T.EA19"))
df <- df[!is.na(value)]
## provider_code dataset_code dataset_name series_code
## 1: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 2: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 3: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 4: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 5: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 6: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## series_name original_period period original_value value
## 1: Annually – (Perc... 1997 1997-01-01 11.5 11.5
## 2: Annually – (Perc... 1998 1998-01-01 11 11.0
## 3: Annually – (Perc... 1999 1999-01-01 10.2 10.2
## 4: Annually – (Perc... 2000 2000-01-01 9.2 9.2
## 5: Annually – (Perc... 2001 2001-01-01 8.4 8.4
## 6: Annually – (Perc... 2002 2002-01-01 8.6 8.6
## @frequency unit Unit geo Country freq Frequency age
## 1: annual percentage-of-ac... NA ea19 NA a Annually NA
## 2: annual percentage-of-ac... NA ea19 NA a Annually NA
## 3: annual percentage-of-ac... NA ea19 NA a Annually NA
## 4: annual percentage-of-ac... NA ea19 NA a Annually NA
## 5: annual percentage-of-ac... NA ea19 NA a Annually NA
## 6: annual percentage-of-ac... NA ea19 NA a Annually NA
## Age class FREQ Geopolitical entity (reporting) indexed_at
## 1: NA NA NA 2020-05-07 08:46:14
## 2: NA NA NA 2020-05-07 08:46:14
## 3: NA NA NA 2020-05-07 08:46:14
## 4: NA NA NA 2020-05-07 08:46:14
## 5: NA NA NA 2020-05-07 08:46:14
## 6: NA NA NA 2020-05-07 08:46:14
## observations_attributes s_adj Seasonal adjustment sex Sex Unit of measure
## 1: NA NA NA NA NA
## 2: NA NA NA NA NA
## 3: NA NA NA NA NA
## 4: NA NA NA NA NA
## 5: NA NA NA NA NA
## 6: NA NA NA NA NA
mask
The code mask notation is a very concise way to select one or many time series at once.
df <- rdb("IMF", "BOP", mask = "A.FR.BCA_BP6_EUR")
df <- df[!is.na(value)]
## provider_code dataset_code dataset_name series_code
## 1: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## 2: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## 3: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## 4: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## 5: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## 6: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## series_name original_period period original_value value
## 1: Annual – France ... 1999 1999-01-01 47672.847 47672.847
## 2: Annual – France ... 2000 2000-01-01 17550.669 17550.669
## 3: Annual – France ... 2001 2001-01-01 23278.392 23278.392
## 4: Annual – France ... 2002 2002-01-01 18718.406 18718.406
## 5: Annual – France ... 2003 2003-01-01 14195.493 14195.493
## 6: Annual – France ... 2004 2004-01-01 7520.754 7520.754
## @frequency FREQ Frequency indexed_at Indicator
## 1: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 2: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 3: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 4: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 5: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 6: annual A Annual 2020-03-26 20:10:01 Current Account,...
## INDICATOR observations_attributes REF_AREA Reference Area
## 1: BCA_BP6_EUR OFFICIAL_BPM,K FR France
## 2: BCA_BP6_EUR OFFICIAL_BPM, FR France
## 3: BCA_BP6_EUR OFFICIAL_BPM, FR France
## 4: BCA_BP6_EUR OFFICIAL_BPM, FR France
## 5: BCA_BP6_EUR OFFICIAL_BPM, FR France
## 6: BCA_BP6_EUR OFFICIAL_BPM, FR France
In the event that you only use the arguments provider_code
, dataset_code
and mask
, you can drop the name mask
and run:
df <- rdb("IMF", "BOP", "A.FR.BCA_BP6_EUR")
You just have to add a +
between two different values of a dimension.
df <- rdb("IMF", "BOP", mask = "A.FR+ES.BCA_BP6_EUR")
df <- df[!is.na(value)]
## provider_code dataset_code dataset_name series_code
## 1: IMF BOP Balance of Payme... A.ES.BCA_BP6_EUR
## 2: IMF BOP Balance of Payme... A.ES.BCA_BP6_EUR
## 3: IMF BOP Balance of Payme... A.ES.BCA_BP6_EUR
## 4: IMF BOP Balance of Payme... A.ES.BCA_BP6_EUR
## 5: IMF BOP Balance of Payme... A.ES.BCA_BP6_EUR
## 6: IMF BOP Balance of Payme... A.ES.BCA_BP6_EUR
## series_name original_period period original_value value
## 1: Annual – Spain –... 1999 1999-01-01 -19295 -19295
## 2: Annual – Spain –... 2000 2000-01-01 -27921 -27921
## 3: Annual – Spain –... 2001 2001-01-01 -30672 -30672
## 4: Annual – Spain –... 2002 2002-01-01 -27959 -27959
## 5: Annual – Spain –... 2003 2003-01-01 -31153 -31153
## 6: Annual – Spain –... 2004 2004-01-01 -47116 -47116
## @frequency FREQ Frequency indexed_at Indicator
## 1: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 2: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 3: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 4: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 5: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 6: annual A Annual 2020-03-26 20:10:01 Current Account,...
## INDICATOR observations_attributes REF_AREA Reference Area
## 1: BCA_BP6_EUR OFFICIAL_BPM,K ES Spain
## 2: BCA_BP6_EUR OFFICIAL_BPM, ES Spain
## 3: BCA_BP6_EUR OFFICIAL_BPM, ES Spain
## 4: BCA_BP6_EUR OFFICIAL_BPM, ES Spain
## 5: BCA_BP6_EUR OFFICIAL_BPM, ES Spain
## 6: BCA_BP6_EUR OFFICIAL_BPM, ES Spain
df <- rdb("IMF", "BOP", mask = "A..BCA_BP6_EUR")
df <- df[!is.na(value)]
df <- df[order(-period, REF_AREA)]
df <- head(df, 100)
## provider_code dataset_code dataset_name series_code
## 1: IMF BOP Balance of Payme... A.DE.BCA_BP6_EUR
## 2: IMF BOP Balance of Payme... A.EE.BCA_BP6_EUR
## 3: IMF BOP Balance of Payme... A.LU.BCA_BP6_EUR
## 4: IMF BOP Balance of Payme... A.LV.BCA_BP6_EUR
## 5: IMF BOP Balance of Payme... A.PT.BCA_BP6_EUR
## 6: IMF BOP Balance of Payme... A.RS.BCA_BP6_EUR
## series_name original_period period original_value value
## 1: Annual – Germany... 2019 2019-01-01 245532 245532.000
## 2: Annual – Estonia... 2019 2019-01-01 615.256 615.256
## 3: Annual – Luxembo... 2019 2019-01-01 2846.74554 2846.746
## 4: Annual – Latvia ... 2019 2019-01-01 -163 -163.000
## 5: Annual – Portuga... 2019 2019-01-01 -181 -181.000
## 6: Annual – Serbia ... 2019 2019-01-01 -3159.86552 -3159.866
## @frequency FREQ Frequency indexed_at Indicator
## 1: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 2: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 3: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 4: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 5: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 6: annual A Annual 2020-03-26 20:10:01 Current Account,...
## INDICATOR observations_attributes REF_AREA Reference Area
## 1: BCA_BP6_EUR OFFICIAL_BPM, DE Germany
## 2: BCA_BP6_EUR OFFICIAL_BPM, EE Estonia
## 3: BCA_BP6_EUR OFFICIAL_BPM, LU Luxembourg
## 4: BCA_BP6_EUR OFFICIAL_BPM, LV Latvia
## 5: BCA_BP6_EUR OFFICIAL_BPM, PT Portugal
## 6: BCA_BP6_EUR OFFICIAL_BPM, RS Serbia
df <- rdb("IMF", "BOP", mask = "A.FR.BCA_BP6_EUR+IA_BP6_EUR")
df <- df[!is.na(value)]
df <- df[order(period), head(.SD, 50), by = INDICATOR]
## provider_code dataset_code dataset_name series_code
## 1: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## 2: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## 3: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## 4: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## 5: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## 6: IMF BOP Balance of Payme... A.FR.BCA_BP6_EUR
## series_name original_period period original_value value
## 1: Annual – France ... 1999 1999-01-01 47672.847 47672.847
## 2: Annual – France ... 2000 2000-01-01 17550.669 17550.669
## 3: Annual – France ... 2001 2001-01-01 23278.392 23278.392
## 4: Annual – France ... 2002 2002-01-01 18718.406 18718.406
## 5: Annual – France ... 2003 2003-01-01 14195.493 14195.493
## 6: Annual – France ... 2004 2004-01-01 7520.754 7520.754
## @frequency FREQ Frequency indexed_at Indicator
## 1: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 2: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 3: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 4: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 5: annual A Annual 2020-03-26 20:10:01 Current Account,...
## 6: annual A Annual 2020-03-26 20:10:01 Current Account,...
## INDICATOR observations_attributes REF_AREA Reference Area
## 1: BCA_BP6_EUR OFFICIAL_BPM,K FR France
## 2: BCA_BP6_EUR OFFICIAL_BPM, FR France
## 3: BCA_BP6_EUR OFFICIAL_BPM, FR France
## 4: BCA_BP6_EUR OFFICIAL_BPM, FR France
## 5: BCA_BP6_EUR OFFICIAL_BPM, FR France
## 6: BCA_BP6_EUR OFFICIAL_BPM, FR France
dimensions
Searching by dimensions
is a less concise way to select time series than using the code mask
, but it works with all the different providers. You have a “Description of series code” at the bottom of each dataset page on the DBnomics website.
df <- rdb("AMECO", "ZUTN", dimensions = list(geo = "ea19"))
df <- df[!is.na(value))]
# or
# df <- rdb("AMECO", "ZUTN", dimensions = '{"geo": ["ea19"]}')
# df <- df[!is.na(value))]
## provider_code dataset_code dataset_name series_code
## 1: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 2: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 3: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 4: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 5: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## 6: AMECO ZUTN Unemployment rat... EA19.1.0.0.0.ZUT...
## series_name original_period period original_value value
## 1: Annually – (Perc... 1998 1998-01-01 10.4 10.4
## 2: Annually – (Perc... 1999 1999-01-01 9.7 9.7
## 3: Annually – (Perc... 2000 2000-01-01 8.9 8.9
## 4: Annually – (Perc... 2001 2001-01-01 8.3 8.3
## 5: Annually – (Perc... 2002 2002-01-01 8.6 8.6
## 6: Annually – (Perc... 2003 2003-01-01 9.1 9.1
## @frequency unit Unit geo Country freq
## 1: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## 2: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## 3: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## 4: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## 5: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## 6: annual percentage-of-ac... (Percentage of a... ea19 Euro area a
## Frequency indexed_at
## 1: Annually 2019-11-08 16:33:50
## 2: Annually 2019-11-08 16:33:50
## 3: Annually 2019-11-08 16:33:50
## 4: Annually 2019-11-08 16:33:50
## 5: Annually 2019-11-08 16:33:50
## 6: Annually 2019-11-08 16:33:50
df <- rdb("AMECO", "ZUTN", dimensions = list(geo = c("ea19", "dnk")))
df <- df[!is.na(value))]
# or
# df <- rdb("AMECO", "ZUTN", dimensions = '{"geo": ["ea19", "dnk"]}')
# df <- df[!is.na(value))]
## provider_code dataset_code dataset_name series_code
## 1: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 2: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 3: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 4: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 5: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 6: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## series_name original_period period original_value value
## 1: Annually – (Perc... 1960 1960-01-01 2 2.0
## 2: Annually – (Perc... 1961 1961-01-01 1.6 1.6
## 3: Annually – (Perc... 1962 1962-01-01 1.4 1.4
## 4: Annually – (Perc... 1963 1963-01-01 2 2.0
## 5: Annually – (Perc... 1964 1964-01-01 1.2 1.2
## 6: Annually – (Perc... 1965 1965-01-01 0.9 0.9
## @frequency unit Unit geo Country freq
## 1: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 2: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 3: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 4: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 5: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 6: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## Frequency indexed_at
## 1: Annually 2019-11-08 16:33:50
## 2: Annually 2019-11-08 16:33:50
## 3: Annually 2019-11-08 16:33:50
## 4: Annually 2019-11-08 16:33:50
## 5: Annually 2019-11-08 16:33:50
## 6: Annually 2019-11-08 16:33:50
df <- rdb("WB", "DB", dimensions = list(country = c("DZ", "PE"), indicator = c("ENF.CONT.COEN.COST.ZS", "IC.REG.COST.PC.FE.ZS")))
df <- df[!is.na(value))]
# or
# df <- rdb("WB", "DB", dimensions = '{"country": ["DZ", "PE"], "indicator": ["ENF.CONT.COEN.COST.ZS", "IC.REG.COST.PC.FE.ZS"]}')
# df <- df[!is.na(value))]
## provider_code dataset_code dataset_name series_code
## 1: WB DB Doing Business IC.REG.COST.PC.F...
## 2: WB DB Doing Business IC.REG.COST.PC.F...
## 3: WB DB Doing Business IC.REG.COST.PC.F...
## 4: WB DB Doing Business IC.REG.COST.PC.F...
## 5: WB DB Doing Business IC.REG.COST.PC.F...
## 6: WB DB Doing Business IC.REG.COST.PC.F...
## series_name original_period period original_value value
## 1: Cost of business... 2003 2003-01-01 16.3 16.3
## 2: Cost of business... 2004 2004-01-01 14.6 14.6
## 3: Cost of business... 2005 2005-01-01 12.4 12.4
## 4: Cost of business... 2006 2006-01-01 13.4 13.4
## 5: Cost of business... 2007 2007-01-01 13.2 13.2
## 6: Cost of business... 2008 2008-01-01 10.8 10.8
## @frequency country Country indexed_at indicator
## 1: annual DZ Algeria 2020-03-11 14:09:09 IC.REG.COST.PC.F...
## 2: annual DZ Algeria 2020-03-11 14:09:09 IC.REG.COST.PC.F...
## 3: annual DZ Algeria 2020-03-11 14:09:09 IC.REG.COST.PC.F...
## 4: annual DZ Algeria 2020-03-11 14:09:09 IC.REG.COST.PC.F...
## 5: annual DZ Algeria 2020-03-11 14:09:09 IC.REG.COST.PC.F...
## 6: annual DZ Algeria 2020-03-11 14:09:09 IC.REG.COST.PC.F...
## Indicator observations_attributes
## 1: Cost of business... ATTRIBUTE,
## 2: Cost of business... ATTRIBUTE,
## 3: Cost of business... ATTRIBUTE,
## 4: Cost of business... ATTRIBUTE,
## 5: Cost of business... ATTRIBUTE,
## 6: Cost of business... ATTRIBUTE,
query
The query is a Google-like search that will filter/select time series from a provider’s dataset.
df <- rdb("IMF", "WEO:2019-10", query = "France current account balance percent")
df <- df[!is.na(value))]
## provider_code dataset_code dataset_name series_code
## 1: IMF WEO:2019-10 WEO by countries... FRA.BCA_NGDPD.pc...
## 2: IMF WEO:2019-10 WEO by countries... FRA.BCA_NGDPD.pc...
## 3: IMF WEO:2019-10 WEO by countries... FRA.BCA_NGDPD.pc...
## 4: IMF WEO:2019-10 WEO by countries... FRA.BCA_NGDPD.pc...
## 5: IMF WEO:2019-10 WEO by countries... FRA.BCA_NGDPD.pc...
## 6: IMF WEO:2019-10 WEO by countries... FRA.BCA_NGDPD.pc...
## series_name original_period period original_value value
## 1: France – Current... 1980 1980-01-01 -0.595 -0.595
## 2: France – Current... 1981 1981-01-01 -0.771 -0.771
## 3: France – Current... 1982 1982-01-01 -2.062 -2.062
## 4: France – Current... 1983 1983-01-01 -0.838 -0.838
## 5: France – Current... 1984 1984-01-01 -0.142 -0.142
## 6: France – Current... 1985 1985-01-01 -0.063 -0.063
## @frequency unit Unit indexed_at weo-country
## 1: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 FRA
## 2: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 FRA
## 3: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 FRA
## 4: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 FRA
## 5: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 FRA
## 6: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 FRA
## weo-subject WEO Country WEO Subject
## 1: BCA_NGDPD France Current account ...
## 2: BCA_NGDPD France Current account ...
## 3: BCA_NGDPD France Current account ...
## 4: BCA_NGDPD France Current account ...
## 5: BCA_NGDPD France Current account ...
## 6: BCA_NGDPD France Current account ...
df <- rdb("IMF", "WEO:2019-10", query = "current account balance percent")
df <- df[!is.na(value))]
## provider_code dataset_code dataset_name series_code
## 1: IMF WEO:2019-10 WEO by countries... DEU.BCA_NGDPD.pc...
## 2: IMF WEO:2019-10 WEO by countries... DEU.BCA_NGDPD.pc...
## 3: IMF WEO:2019-10 WEO by countries... DEU.BCA_NGDPD.pc...
## 4: IMF WEO:2019-10 WEO by countries... DEU.BCA_NGDPD.pc...
## 5: IMF WEO:2019-10 WEO by countries... DEU.BCA_NGDPD.pc...
## 6: IMF WEO:2019-10 WEO by countries... DEU.BCA_NGDPD.pc...
## series_name original_period period original_value value
## 1: Germany – Curren... 1980 1980-01-01 -1.782 -1.782
## 2: Germany – Curren... 1981 1981-01-01 -0.684 -0.684
## 3: Germany – Curren... 1982 1982-01-01 0.866 0.866
## 4: Germany – Curren... 1983 1983-01-01 0.666 0.666
## 5: Germany – Curren... 1984 1984-01-01 1.423 1.423
## 6: Germany – Curren... 1985 1985-01-01 2.662 2.662
## @frequency unit Unit indexed_at weo-country
## 1: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 DEU
## 2: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 DEU
## 3: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 DEU
## 4: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 DEU
## 5: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 DEU
## 6: annual pcent_gdp Percent of GDP 2020-10-14 14:39:56 DEU
## weo-subject WEO Country WEO Subject
## 1: BCA_NGDPD Germany Current account ...
## 2: BCA_NGDPD Germany Current account ...
## 3: BCA_NGDPD Germany Current account ...
## 4: BCA_NGDPD Germany Current account ...
## 5: BCA_NGDPD Germany Current account ...
## 6: BCA_NGDPD Germany Current account ...
When you don’t know the codes of the dimensions, provider, dataset or series, you can:
go to the page of a dataset on DBnomics website, for example Doing Business,
select some dimensions by using the input widgets of the left column,
click on “Copy API link” in the menu of the “Download” button,
use the rdb(api_link = ...)
function such as below.
df <- rdb(api_link = "https://api.db.nomics.world/v22/series/WB/DB?dimensions=%7B%22country%22%3A%5B%22FR%22%2C%22IT%22%2C%22ES%22%5D%7D&q=IC.REG.PROC.FE.NO&observations=1&format=json&align_periods=1&offset=0&facets=0")
df <- df[!is.na(value))]
## provider_code dataset_code dataset_name series_code
## 1: WB DB Doing Business IC.REG.PROC.FE.N...
## 2: WB DB Doing Business IC.REG.PROC.FE.N...
## 3: WB DB Doing Business IC.REG.PROC.FE.N...
## 4: WB DB Doing Business IC.REG.PROC.FE.N...
## 5: WB DB Doing Business IC.REG.PROC.FE.N...
## 6: WB DB Doing Business IC.REG.PROC.FE.N...
## series_name original_period period original_value value
## 1: Starting a busin... 2004 2004-01-01 8 8
## 2: Starting a busin... 2004 2004-01-01 10 10
## 3: Starting a busin... 2004 2004-01-01 10 10
## 4: Starting a busin... 2005 2005-01-01 5 5
## 5: Starting a busin... 2005 2005-01-01 10 10
## 6: Starting a busin... 2005 2005-01-01 10 10
## @frequency country Country indexed_at indicator
## 1: annual FR France 2020-03-11 14:09:09 IC.REG.PROC.FE.N...
## 2: annual IT Italy 2020-03-11 14:09:09 IC.REG.PROC.FE.N...
## 3: annual ES Spain 2020-03-11 14:09:09 IC.REG.PROC.FE.N...
## 4: annual FR France 2020-03-11 14:09:09 IC.REG.PROC.FE.N...
## 5: annual IT Italy 2020-03-11 14:09:09 IC.REG.PROC.FE.N...
## 6: annual ES Spain 2020-03-11 14:09:09 IC.REG.PROC.FE.N...
## Indicator observations_attributes
## 1: Starting a busin... ATTRIBUTE,
## 2: Starting a busin... ATTRIBUTE,
## 3: Starting a busin... ATTRIBUTE,
## 4: Starting a busin... ATTRIBUTE,
## 5: Starting a busin... ATTRIBUTE,
## 6: Starting a busin... ATTRIBUTE,
In the event that you only use the argument api_link
, you can drop the name and run:
df <- rdb("https://api.db.nomics.world/v22/series/WB/DB?dimensions=%7B%22country%22%3A%5B%22FR%22%2C%22IT%22%2C%22ES%22%5D%7D&q=IC.REG.PROC.FE.NO&observations=1&format=json&align_periods=1&offset=0&facets=0")
rdb(api_link = ...)
function. Please note that when you update your cart, you have to copy this link again, because the link itself contains the ids of the series in the cart.
df <- rdb(api_link = "https://api.db.nomics.world/v22/series?observations=1&series_ids=BOE/6008/RPMTDDC,BOE/6231/RPMTBVE")
df <- df[!is.na(value))]
## provider_code dataset_code dataset_name series_code
## 1: BOE 6008 Industrial analy... RPMTDDC
## 2: BOE 6231 Industrial analy... RPMTBVE
## 3: BOE 6008 Industrial analy... RPMTDDC
## 4: BOE 6231 Industrial analy... RPMTBVE
## 5: BOE 6008 Industrial analy... RPMTDDC
## 6: BOE 6231 Industrial analy... RPMTBVE
## series_name original_period period original_value value
## 1: Monthly amounts ... 2009-07 2009-07-01 10150 10150
## 2: Monthly amounts ... 2009-07 2009-07-01 11066 11066
## 3: Monthly amounts ... 2009-08 2009-08-01 10400 10400
## 4: Monthly amounts ... 2009-08 2009-08-01 11260 11260
## 5: Monthly amounts ... 2009-09 2009-09-01 11595 11595
## 6: Monthly amounts ... 2009-09 2009-09-01 11208 11208
## @frequency freq Freq indexed_at Instrument Currency
## 1: monthly M Monthly 2020-03-31 08:03:49 Sterling
## 2: monthly M Monthly 2020-03-31 08:03:49 Sterling
## 3: monthly M Monthly 2020-03-31 08:03:49 Sterling
## 4: monthly M Monthly 2020-03-31 08:03:49 Sterling
## 5: monthly M Monthly 2020-03-31 08:03:49 Sterling
## 6: monthly M Monthly 2020-03-31 08:03:49 Sterling
## INSTRUMENT_CURRENCY Instruments INSTRUMENTS Of Sector
## 1: £ Deposits and rep... LDPRP Education provid...
## 2: £ Lending - total ALENDG Education provid...
## 3: £ Deposits and rep... LDPRP Education provid...
## 4: £ Lending - total ALENDG Education provid...
## 5: £ Deposits and rep... LDPRP Education provid...
## 6: £ Lending - total ALENDG Education provid...
## OF_SECTOR Output In OUTPUT_IN Seasonal Adjustment SEASONAL_ADJUSTMENT
## 1: ED Sterling £ Not seasonally a... U
## 2: ED Sterling £ Not seasonally a... U
## 3: ED Sterling £ Not seasonally a... U
## 4: ED Sterling £ Not seasonally a... U
## 5: ED Sterling £ Not seasonally a... U
## 6: ED Sterling £ Not seasonally a... U
## Sector SECTOR Type TYPE
## 1: UK resident mone... BKBS Amounts outstand... L
## 2: UK resident mone... BKBS Amounts outstand... L
## 3: UK resident mone... BKBS Amounts outstand... L
## 4: UK resident mone... BKBS Amounts outstand... L
## 5: UK resident mone... BKBS Amounts outstand... L
## 6: UK resident mone... BKBS Amounts outstand... L
When fetching series from DBnomics, you need to give a provider and a dataset before specifying correct dimensions. With the function rdb_datasets
, you can download the list of the available datasets for a provider.
For example, to fetch the IMF datasets, you have to use:
rdb_datasets(provider_code = "IMF")
The result is a named list (its name is IMF) with one element which is a data.table
:
## List of 1
## $ IMF:Classes 'data.table' and 'data.frame': 17 obs. of 2 variables:
## ..$ code: chr [1:17] "BOP" "BOPAGG" "COMMP" "COMMPP" ...
## ..$ name: chr [1:17] "Balance of Payments (BOP)" "Balance of Payments (BOP), World and Regional Aggregates" "Primary Commodity Prices" "Primary Commodity Prices Projections" ...
## ..- attr(*, ".internal.selfref")=<externalptr>
With the same function, if you want to fetch the available datasets for multiple providers, you can give a vector of providers and get a named list.
rdb_datasets(provider_code = c("IMF", "BDF"))
## List of 2
## $ IMF:Classes 'data.table' and 'data.frame': 17 obs. of 2 variables:
## ..$ code: chr [1:17] "BOP" "BOPAGG" "COMMP" "COMMPP" ...
## ..$ name: chr [1:17] "Balance of Payments (BOP)" "Balance of Payments (BOP), World and Regional Aggregates" "Primary Commodity Prices" "Primary Commodity Prices Projections" ...
## ..- attr(*, ".internal.selfref")=<externalptr>
## $ BDF:Classes 'data.table' and 'data.frame': 45 obs. of 2 variables:
## ..$ code: chr [1:45] "AME" "BLS" "BPM6" "BSI" ...
## ..$ name: chr [1:45] "Macro Economy - Euro Area" "Bank Lending Survey" "Balance of payments- 6th manual" "Monetary Statistics - Euro Area" ...
## ..- attr(*, ".internal.selfref")=<externalptr>
## Number of datasets for IMF : 17
## Number of datasets for BDF : 45
In the event that you only request the datasets for one provider, if you define simplify = TRUE
, then the result will be a data.table
not a named list.
rdb_datasets(provider_code = "IMF", simplify = TRUE)
## code name
## 1: BOP Balance of Payme...
## 2: BOPAGG Balance of Payme...
## 3: COMMP Primary Commodit...
## 4: COMMPP Primary Commodit...
## 5: CPI Consumer Price I...
## 6: CPIS Coordinated Port...
The extent of datasets gathered by DBnomics can be appreciate by using the function with the argument provider_code
set to NULL
:
options(rdbnomics.progress_bar_datasets = TRUE)
rdb_datasets()
options(rdbnomics.progress_bar_datasets = FALSE)
## Provider Number of datasets
## 1: AFDB 1
## 2: AMECO 481
## 3: BCB 85
## 4: BCEAO 28
## 5: BDF 45
## 6: BEA 555
When fetching series from DBnomics, it can be interesting and especially useful to specify dimensions for a particular dataset to download only the series you want to analyse. With the function rdb_dimensions
, you can download these dimensions and their meanings.
For example, for the dataset WEO:2019-10 of the IMF, you may use:
rdb_dimensions(provider_code = "IMF", dataset_code = "WEO:2019-10")
The result is a nested named list (its names are IMF, WEO:2019-10 and the dimensions names) with a data.table
at the end of each branch:
## Number of dimensions for IMF/WEO:2019-10 : 3
## unit Unit
## 1: idx Index
## 2: national_currenc... National currenc...
## 3: national_currenc... National currenc...
## 4: pcent Percent
## 5: pcent_change Percent change
## 6: pcent_gdp Percent of GDP
## weo-country WEO Country
## 1: ABW Aruba
## 2: AFG Afghanistan
## 3: AGO Angola
## 4: ALB Albania
## 5: ARE United Arab Emir...
## 6: ARG Argentina
## weo-subject WEO Subject
## 1: BCA Current account ...
## 2: BCA_NGDPD Current account ...
## 3: FLIBOR6 Six-month London...
## 4: GGR General governme...
## 5: GGR_NGDP General governme...
## 6: GGSB General governme...
In the event that you only request the dimensions for one dataset for one provider, if you define simplify = TRUE
, then the result will be a named list data.table
not a nested named list.
rdb_dimensions(provider_code = "IMF", dataset_code = "WEO:2019-10", simplify = TRUE)
## List of 3
## $ unit :Classes 'data.table' and 'data.frame': 12 obs. of 2 variables:
## ..$ unit: chr [1:12] "idx" "national_currency" "national_currency_per_current_international_dollar" "pcent" ...
## ..$ Unit: chr [1:12] "Index" "National currency" "National currency per current international dollar" "Percent" ...
## ..- attr(*, ".internal.selfref")=<externalptr>
## $ weo-country:Classes 'data.table' and 'data.frame': 194 obs. of 2 variables:
## ..$ weo-country: chr [1:194] "ABW" "AFG" "AGO" "ALB" ...
## ..$ WEO Country: chr [1:194] "Aruba" "Afghanistan" "Angola" "Albania" ...
## ..- attr(*, ".internal.selfref")=<externalptr>
## $ weo-subject:Classes 'data.table' and 'data.frame': 45 obs. of 2 variables:
## ..$ weo-subject: chr [1:45] "BCA" "BCA_NGDPD" "FLIBOR6" "GGR" ...
## ..$ WEO Subject: chr [1:45] "Current account balance" "Current account balance" "Six-month London interbank offered rate (LIBOR)" "General government revenue" ...
## ..- attr(*, ".internal.selfref")=<externalptr>
You can measure the vast extent of datasets gathered by DBnomics by downloading all the possible dimensions. To do this, you have to set the arguments provider_code
and dataset_code
to NULL
.
⚠ It’s relatively long to run and heavy to show so we display the first 100.
options(rdbnomics.progress_bar_datasets = TRUE)
rdb_dimensions()
options(rdbnomics.progress_bar_datasets = FALSE)
## Provider Dataset Dimension Number of codes
## 1: AFDB bbkawjf country 109
## 2: AFDB bbkawjf frequency 1
## 3: AFDB bbkawjf indicator 1279
## 4: AFDB bbkawjf scale 1
## 5: AFDB bbkawjf units 169
## 6: AMECO AAGE freq 1
You can download the list of series, and especially their codes, of a dataset’s provider by using the function rdb_series
. The result is a nested named list with a data.table
at the end of each branch. If you define simplify = TRUE
, then the result will be a data.table
not a nested named list.
For example, for the IMF provider and the dataset WEO:2019-10, the command is (only first 100):
rdb_series(provider_code = "IMF", dataset_code = "WEO:2019-10", simplify = TRUE)
## series_code series_name
## 1: ABW.BCA.us_dolla... Aruba – Current ...
## 2: ABW.BCA_NGDPD.pc... Aruba – Current ...
## 3: ABW.FLIBOR6.pcen... Aruba – Six-mont...
## 4: ABW.GGR.national... Aruba – General ...
## 5: ABW.GGR_NGDP.pce... Aruba – General ...
## 6: ABW.GGSB.nationa... Aruba – General ...
Like the function rdb()
, you can add features to rdb_series()
. You can ask for the series with specific dimensions
:
rdb_series(provider_code = "IMF", dataset_code = "WEO:2019-10", dimensions = list(`weo-subject` = "NGDP_RPCH"), simplify = TRUE)
or with a query
:
rdb_series(provider_code = "IMF", dataset_code = c("WEO:2019-10", "WEOAGG:2019-10"), query = "NGDP_RPCH")
⚠ We ask the user to use this function parsimoniously because there are a huge amount of series per dataset. Please only fetch for one dataset if you need it or visit the website https://db.nomics.world.
For example, for the IMF provider, the number of series is (only first 5):
## Dataset Number of series
## 1: CPIS 2903710
## 2: CDIS 772274
## 3: GFSIBS 681984
## 4: BOP 535322
## 5: DOT 459980
Could not resolve host
When using the function rdb
, you may come across the following error:
Error in open.connection(con, "rb") :
Could not resolve host: api.db.nomics.world
To get round this situation, you have two options:
configure curl to use a specific and authorized proxy.
use the default R internet connection i.e. the Internet Explorer proxy defined in internet2.dll.
To retrieve the data with the default R internet connection, rdbnomics will use the base function readLines
.
To activate this feature for a session, you need to enable an option of the package:
options(rdbnomics.use_readLines = TRUE)
And then use the standard function as follows:
df1 <- rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN")
This configuration can be disabled with:
options(rdbnomics.use_readLines = FALSE)
If you just want to do it once, you may use the argument use_readLines
of the function rdb
:
df1 <- rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN", use_readLines = TRUE)
The rdbnomics package can interact with the Time Series Editor of DBnomics to transform time series by applying filters to them.
Available filters are listed on the filters page https://editor.nomics.world/filters.
Here is an example of how to proceed to interpolate two annual time series with a monthly frequency, using a spline interpolation:
filters <- list(
code = "interpolate",
parameters = list(frequency = "monthly", method = "spline")
)
The request is then:
df <- rdb(
ids = c("AMECO/ZUTN/EA19.1.0.0.0.ZUTN", "AMECO/ZUTN/DNK.1.0.0.0.ZUTN"),
filters = filters
)
If you want to apply more than one filter, the filters
argument will be a list of valid filters:
filters <- list(
list(
code = "interpolate",
parameters = list(frequency = "monthly", method = "spline")
),
list(
code = "aggregate",
parameters = list(frequency = "bi-annual", method = "end_of_period")
)
)
df <- rdb(
ids = c("AMECO/ZUTN/EA19.1.0.0.0.ZUTN", "AMECO/ZUTN/DNK.1.0.0.0.ZUTN"),
filters = filters
)
The data.table
columns change a little bit when filters are used. There are two new columns:
period_middle_day
: the middle day of original_period
(can be useful when you compare graphically interpolated series and original ones).filtered
(boolean): TRUE
if the series is filtered, FALSE
otherwise.The content of two columns are modified:
series_code
: same as before for original series, but the suffix _filtered
is added for filtered series.series_name
: same as before for original series, but the suffix (filtered)
is added for filtered series.## provider_code dataset_code dataset_name series_code
## 1: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 2: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 3: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 4: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 5: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## 6: AMECO ZUTN Unemployment rat... DNK.1.0.0.0.ZUTN
## series_name original_period period original_value value
## 1: Annually – (Perc... 1960 1960-01-01 2 2.0
## 2: Annually – (Perc... 1961 1961-01-01 1.6 1.6
## 3: Annually – (Perc... 1962 1962-01-01 1.4 1.4
## 4: Annually – (Perc... 1963 1963-01-01 2 2.0
## 5: Annually – (Perc... 1964 1964-01-01 1.2 1.2
## 6: Annually – (Perc... 1965 1965-01-01 0.9 0.9
## @frequency unit Unit geo Country freq
## 1: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 2: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 3: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 4: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 5: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## 6: annual percentage-of-ac... (Percentage of a... dnk Denmark a
## Frequency filtered indexed_at period_middle_day
## 1: Annually FALSE 2019-11-08 16:33:50 <NA>
## 2: Annually FALSE 2019-11-08 16:33:50 <NA>
## 3: Annually FALSE 2019-11-08 16:33:50 <NA>
## 4: Annually FALSE 2019-11-08 16:33:50 <NA>
## 5: Annually FALSE 2019-11-08 16:33:50 <NA>
## 6: Annually FALSE 2019-11-08 16:33:50 <NA>
Banque de France, https://github.com/s915↩︎
CEPREMAP↩︎