library(xts) library(gdata) library(ggplot2) library(grid) library(Quandl) load(url("http://statrstart.github.io/data/d2010_2015.RData")) temp <- tempfile() download.file("http://www3.boj.or.jp/market/jp/pastetfreit.zip",temp) con <- unzip(temp, "2016.xls") d201601_03 <- read.xls(con,header=F,skip=8) unlink(temp) temp <- tempfile() download.file("http://www3.boj.or.jp/market/jp/etfreit.zip",temp) con <- unzip(temp, "2016.xls") d201604 <- read.xls(con,header=F,skip=8) unlink(temp) d2016<-rbind(d201601_03[,2:4],d201604[,2:4]) names(d2016)<-c("date","ETF","REIT") d2016$ETF[is.na(d2016$ETF)]<-0 d2016$REIT[is.na(d2016$REIT)]<-0 d2010_2016<-rbind(d2010_2015,d2016) x <- read.zoo(d2010_2016) a<-ggplot(data = fortify(cumsum(x[,1]), melt = TRUE),aes(x = Index, y = Value) ) + geom_bar(stat="identity",position=position_dodge(),fill=rgb(1,0,0,alpha=0.7)) + labs(title=paste("日銀買い入れ:累計(ETF) ",d2010_2016[1,"date"],"_",d2010_2016[nrow(d2010_2016),"date"]), x="", y="") b<-ggplot(data = fortify(cumsum(x[,2]), melt = TRUE),aes(x = Index, y = Value) ) + geom_bar(stat="identity",position=position_dodge(),fill=rgb(0,0,1,alpha=0.7)) + labs(title=paste("日銀買い入れ:累計(REIT) ",d2010_2016[1,"date"],"_",d2010_2016[nrow(d2010_2016),"date"]), x="", y="") grid.newpage() pushViewport(viewport(layout=grid.layout(2, 1))) print(a, vp=viewport(layout.pos.row=1)) print(b, vp=viewport(layout.pos.row=2))
|