Pythonの寿命と配偶関係のR版。
df = read.csv("c070000.csv", fileEncoding="CP932", skip=5, header=FALSE, na.strings="-", col.names=c("階級","総数", "男総数","男有配偶","男未婚","男死別","男離別","男不詳", "女総数","女有配偶","女未婚","女死別","女離別","女不詳")) df[is.na(df)] = 0 matplot(seq(15,100,5), df[c("男有配偶","男未婚","男死別","男離別")], type="o", pch=15:18, xlab="死亡年齢", ylab="死亡数", lty=1, col=1:4) legend("topleft", c("男有配偶","男未婚","男死別","男離別"), pch=15:18, col=1:4, lty=1)
縦軸の範囲を設定するには matplot()
に ylim=c(0,135000)
のようなオプションを付ける。
Last modified: