if (!require(fmsb)) { install.packages("fmsb"); library(fmsb) } p20s <- function(x) { sum(Jfert[6:15, x])/sum(Jfert[, x]) } pp20s <- Vectorize(p20s) p30s <- function(x) { sum(Jfert[16:25, x])/sum(Jfert[, x]) } pp30s <- Vectorize(p30s) par(las=1) layout(1:2) matplot(1950+0:12*5, cbind(a<-pp20s(2:14), b<-pp30s(2:14), a+b), type="b", lty=1:3, lwd=2, pch=16, col=1:3, ylim=c(0, 1), main="TFR‚Éè‚ß‚é20-39ÎASFR‚ÌŠñ—^Š„‡", xlab="”NŽŸ", ylab="Šñ—^Š„‡") legend("bottomright", lty=1:3, lwd=2, pch=16, col=1:3, legend=c("20‘ã", "30‘ã", "20-39Î")) lines(c(1950, 2010), c(0.95, 0.95), col="blue") matplot(1950+0:12*5, cbind(a<-pp20s(15:27), b<-pp30s(15:27), a+b), type="b", lty=1:3, lwd=2, pch=16, col=1:3, ylim=c(0, 1), main="TMFR‚Éè‚ß‚é20-39ÎASMFR‚ÌŠñ—^Š„‡", xlab="”NŽŸ", ylab="Šñ—^Š„‡") legend("topright", lty=1:3, lwd=2, pch=16, col=1:3, legend=c("20‘ã", "30‘ã", "20-39Î"))