- Notifications
You must be signed in to change notification settings - Fork1
R Interface to Bank of Japan Statistics
License
stefanangrick/BOJ
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
TheBOJ package provides anR interface toBank ofJapan statistics, specifically theflatfiles availableon theBOJ Time-Series Dataportal.
You can install the package from CRAN or GitHub.
library(devtools)install_github("stefanangrick/BOJ")# GitHubinstall.packages("BOJ")# CRAN
To start using the package, load it into your R session.
library("BOJ")Next, retrieve a list of available data sets using theget_boj_datasets() function.
ds<- get_boj_datasets()head(ds)
## # A tibble: 6 × 3## desc name url ## <chr> <chr> <chr>## 1 Corporate Goods Price Index (CGPI) cgpi… http…## 2 Producer Price Index using chain-weighted index formula cgpi… http…## 3 Services Producer Price Index (SPPI) sppi… http…## 4 Wholesale Services Price Index, and Research and development Serv… sppi… http…## 5 Flow of Funds fof http…## 6 Flow of Funds (with name of time-series, etc.) fof2… http…Theget_boj_datasets() function returns atibble data frame listing availabledata sets. Use theurl column as input for theget_boj() function todownload, parse, and import the corresponding data set.
For example, to import monthly-frequency data on Japan’sServicesProducer PriceIndex, usethe following code:
sppi<- get_boj(ds$url[(ds$name=="sppi_m_en")])head(sppi)
## # A tibble: 6 × 5## code desc struc date obs_value## <chr> <chr> <chr> <chr> <dbl>## 1 PRCS20_5200000000 Services Producer Price Index (2020 b… [Bas… 2020… 101. ## 2 PRCS20_5200000000 Services Producer Price Index (2020 b… [Bas… 2020… 101. ## 3 PRCS20_5200000000 Services Producer Price Index (2020 b… [Bas… 2020… 101. ## 4 PRCS20_5200000000 Services Producer Price Index (2020 b… [Bas… 2020… 99.4## 5 PRCS20_5200000000 Services Producer Price Index (2020 b… [Bas… 2020… 98.8## 6 PRCS20_5200000000 Services Producer Price Index (2020 b… [Bas… 2020… 99.3To plot the data withggplot2, run thefollowing:
library("dplyr")library("ggplot2")library("zoo")sppi_plot<- subset(sppi,code%in% c("PRCS20_5200000000","PRCS20_5200010001","PRCS20_5200010002","PRCS20_5200010003","PRCS20_5200010004","PRCS20_5200010005","PRCS20_5200010006","PRCS20_5200010007"))sppi_plot<- mutate(sppi_plot,date= as.Date(as.yearmon(date,format="%Y%m")))sppi_plot<- mutate(sppi_plot,struc= gsub("^Major group/","",struc))sppi_plot<- subset(sppi_plot,!is.na(obs_value))ggplot(sppi_plot, aes(x=date,y=obs_value))+ geom_line(aes(colour=struc))+ labs(title="Services Producer Price Index",x="Date",y="Index")+ theme(legend.title= element_blank())
Note that BOJ data sets use various time formats. Thezoo package (e.g.,as.yearmon()) can handle most of these formats.
To retrieve individual data series instead of full data sets, considerusing theBOJfame package.
This package is neither officially related to nor endorsed by theBankof Japan. Please avoid overloading the BOJservers with unnecessary requests.
About
R Interface to Bank of Japan Statistics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
