japanese governement bond jgb historical data
#get Japan yield data from the Ministry of Finance Japan | |
#data goes back to 1974 | |
require(latticeExtra) | |
require(xtsExtra) | |
url <- "http://www.mof.go.jp/english/jgbs/reference/interest_rate/" | |
filenames <- paste("jgbcme",c("","_2010","_2000-2009","_1990-1999","_1980-1989","_1974-1979"),".csv",sep="") | |
#load all data and combine into one jgb data.frame | |
jgb <- read.csv(paste(url,filenames[1],sep=""),stringsAsFactors=FALSE) | |
for (i in 2:length(filenames)) { | |
jgb <- rbind(jgb,read.csv(paste(url,"/historical/",filenames[i],sep=""),stringsAsFactors=FALSE)) | |
} | |
#now clean up the jgb data.frame to make a jgb xts | |
jgb.xts <- as.xts(data.matrix(jgb[,2:NCOL(jgb)]),order.by=as.Date(jgb[,1])) | |
plot.xts(jgb.xts,ylim=c(0,12),screens=1,las=1) | |
plot.xts(jgb.xts,ylim=c(0,12),screens=c(rep(1,5),rep(2,5),rep(3,5)),las=1) | |
#use lattice to do the same thing | |
#for the sake of time will do final formatting here | |
xyplot(jgb.xts,col=brewer.pal("Blues",n=9)[5:9], | |
ylim=c(0,12), | |
screens=c(rep(1,5),rep(2,5),rep(3,5)), | |
lattice.options=theEconomist.opts(), | |
par.settings=theEconomist.theme(box="transparent"), | |
scale=list(y=list(rot=0)), | |
strip=strip.custom(factor.levels=c("1-5 Year","5-10 Year","10-40 Year"),style=5), | |
main="Japanese Government Bonds Since 1974") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment