load(url("http://statrstart.github.io/data/popJA1994_2015.RData"))
df <- popJA1994_2015[popJA1994_2015$Age=="Total",]
yen<-(meimokuGDP)*1e+9/ts(rep(df$BothSexes,each=4),start=1994,freq=4)
dol<-(meimokuGDP/dy1994_2015_4)*1e+9/ts(rep(df$BothSexes,each=4),start=1994,freq=4)
z <- data.frame(as.matrix(time(yen)),as.matrix(yen))
names(z)<-c("date","gdp")
p1<-ggplot(data=z,aes(x=date, y=gdp))+ geom_line() +geom_point()+
theme(text=element_text(size=12,family="IPAexMincho")) +
ggtitle("国民一人あたり名目GDP(単位:円)") +
annotate("rect", fill = "red", alpha = 0.2,
xmin=2013,xmax=2015 + 3/4,ymin=-Inf,ymax=Inf )
z <- data.frame(as.matrix(time(dol)),as.matrix(dol))
names(z)<-c("date","gdp")
p2<-ggplot(data=z,aes(x=date, y=gdp))+ geom_line() +geom_point()+
theme(text=element_text(size=12,family="Ume Mincho")) +
ggtitle("国民一人あたり名目GDP(ドル換算 単位:ドル)") +
annotate("rect", fill = "red", alpha = 0.2,
xmin=2013,xmax=2015 + 3/4,ymin=-Inf,ymax=Inf )
grid.newpage()
pushViewport(viewport(layout=grid.layout(2,1)))
print(p1,vp=viewport(layout.pos.row=1))
print(p2,vp=viewport(layout.pos.row=2))