source("http://minato.sip21c.org/demography/demogjpn.R") library(pyramid) for (Yr in c(0:6*5+1888,0:4*5+1920,1947,0:11*5+1950)) { png(sprintf("Pyramid%d.png",Yr),width=400,height=400) Males <- Jpop[,sprintf("M%d",Yr)]/10000 Females <- Jpop[,sprintf("F%d",Yr)]/10000 Ages <- Jpop[,"Age"] pyramid(data.frame(Males,Females,Ages),Cstep=10, Laxis=0:4*50, Lcol=c(rep("cyan",65),rep("navy",21)), Rcol=c(rep("pink",65),rep("red",21)),main=sprintf("%d",Yr)) dev.off() }