【R】都道府県別 出生数・合計特殊出生率
2020年6月8日
厚生労働省が、6月5日に令和元年(2019)人口動態統計月報年計(概数)の概況を発表しました。少子高齢化社会として心配なのは、やはり出生率です。この統計では、1人の女性が生涯に生む子どもの数にあたる合計特殊出生率も公表され、1.36と前年より0.06ポイント下がりました。これは、4年連続の低下で2007年以来12年ぶりの低水準だそうです。このページにある統計表(xlsファイル)から、都道府県別の出生数と合計特殊出生率を示してみます。

|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
library(leaflet)
library(knitr)
library(kableExtra)
library(dplyr)
library(tidyr)
library(stringr)
dat <- read.csv("http://www.dinov.tokyo/Data/JP_Pref/Pref_data.csv", header = TRUE, fileEncoding="UTF-8")
col_start <- 0.2
col_end <- 0.0
table_df<-data.frame(都道府県=dat$都道府県, 出生数_2019=dat$出生数_2019, 合計特殊出生率_2019=dat$合計特殊出生率_2019)
datc_k <- cut(dat$出生数_2019, hist(dat$出生数_2019, plot=FALSE)$breaks, right=FALSE)
datc_kcol <- rainbow(length(levels(datc_k)), start = col_start, end=col_end)[as.integer(datc_k)]
datc_m <- cut(dat$合計特殊出生率_2019, hist(dat$合計特殊出生率_2019, plot=FALSE)$breaks, right=FALSE)
datc_mcol <- rainbow(length(levels(datc_m)), start = col_start, end=col_end)[as.integer(datc_m)]
library(NipponMap)
windowsFonts(JP4=windowsFont("Biz Gothic"))
windows(width=1600, height=800)
png("0plot1.png", width = 1600, height = 800)
par(family="JP4")
layout(matrix(1:2, 1, 2))
JapanPrefMap(datc_kcol, main="出生数_2019")
legend("bottomright", fill=rainbow(length(levels(datc_k)), start = col_start, end=col_end), legend=names(table(datc_k)))
JapanPrefMap(datc_mcol, main="合計特殊出生率_2019")
legend("bottomright", fill=rainbow(length(levels(datc_m)), start = col_start, end=col_end), legend=names(table(datc_m)))
dev.off()
library(clipr)
t1=kable(table_df[c(1:24),], align = "c", row.names=FALSE) %>%
kable_styling(full_width = F) %>%
column_spec(1, bold = T) %>%
collapse_rows(columns = 1, valign = "middle")
t2=kable(table_df[c(25:47),], align = "c", row.names=FALSE) %>%
kable_styling(full_width = F) %>%
column_spec(1, bold = T) %>%
collapse_rows(columns = 1, valign = "middle")
paste(c('<table><tr valign="top"><td>', t1, '</td><td>', t2, '</td><tr></table>'), sep = '') %>% write_clip
library(leaflet)
library(knitr)
library(kableExtra)
library(dplyr)
library(tidyr)
library(stringr)
dat <- read.csv("http://www.dinov.tokyo/Data/JP_Pref/Pref_data.csv", header = TRUE, fileEncoding="UTF-8")
col_start <- 0.2
col_end <- 0.0
table_df<-data.frame(都道府県=dat$都道府県, 出生数_2019=dat$出生数_2019, 合計特殊出生率_2019=dat$合計特殊出生率_2019)
datc_k <- cut(dat$出生数_2019, hist(dat$出生数_2019, plot=FALSE)$breaks, right=FALSE)
datc_kcol <- rainbow(length(levels(datc_k)), start = col_start, end=col_end)[as.integer(datc_k)]
datc_m <- cut(dat$合計特殊出生率_2019, hist(dat$合計特殊出生率_2019, plot=FALSE)$breaks, right=FALSE)
datc_mcol <- rainbow(length(levels(datc_m)), start = col_start, end=col_end)[as.integer(datc_m)]
library(NipponMap)
windowsFonts(JP4=windowsFont("Biz Gothic"))
windows(width=1600, height=800)
png("0plot1.png", width = 1600, height = 800)
par(family="JP4")
layout(matrix(1:2, 1, 2))
JapanPrefMap(datc_kcol, main="出生数_2019")
legend("bottomright", fill=rainbow(length(levels(datc_k)), start = col_start, end=col_end), legend=names(table(datc_k)))
JapanPrefMap(datc_mcol, main="合計特殊出生率_2019")
legend("bottomright", fill=rainbow(length(levels(datc_m)), start = col_start, end=col_end), legend=names(table(datc_m)))
dev.off()
library(clipr)
t1=kable(table_df[c(1:24),], align = "c", row.names=FALSE) %>%
kable_styling(full_width = F) %>%
column_spec(1, bold = T) %>%
collapse_rows(columns = 1, valign = "middle")
t2=kable(table_df[c(25:47),], align = "c", row.names=FALSE) %>%
kable_styling(full_width = F) %>%
column_spec(1, bold = T) %>%
collapse_rows(columns = 1, valign = "middle")
paste(c('<table><tr valign="top"><td>', t1, '</td><td>', t2, '</td><tr></table>'), sep = '') %>% write_clip
library(leaflet) library(knitr) library(kableExtra) library(dplyr) library(tidyr) library(stringr) dat <- read.csv("http://www.dinov.tokyo/Data/JP_Pref/Pref_data.csv", header = TRUE, fileEncoding="UTF-8") col_start <- 0.2 col_end <- 0.0 table_df<-data.frame(都道府県=dat$都道府県, 出生数_2019=dat$出生数_2019, 合計特殊出生率_2019=dat$合計特殊出生率_2019) datc_k <- cut(dat$出生数_2019, hist(dat$出生数_2019, plot=FALSE)$breaks, right=FALSE) datc_kcol <- rainbow(length(levels(datc_k)), start = col_start, end=col_end)[as.integer(datc_k)] datc_m <- cut(dat$合計特殊出生率_2019, hist(dat$合計特殊出生率_2019, plot=FALSE)$breaks, right=FALSE) datc_mcol <- rainbow(length(levels(datc_m)), start = col_start, end=col_end)[as.integer(datc_m)] library(NipponMap) windowsFonts(JP4=windowsFont("Biz Gothic")) windows(width=1600, height=800) png("0plot1.png", width = 1600, height = 800) par(family="JP4") layout(matrix(1:2, 1, 2)) JapanPrefMap(datc_kcol, main="出生数_2019") legend("bottomright", fill=rainbow(length(levels(datc_k)), start = col_start, end=col_end), legend=names(table(datc_k))) JapanPrefMap(datc_mcol, main="合計特殊出生率_2019") legend("bottomright", fill=rainbow(length(levels(datc_m)), start = col_start, end=col_end), legend=names(table(datc_m))) dev.off() library(clipr) t1=kable(table_df[c(1:24),], align = "c", row.names=FALSE) %>% kable_styling(full_width = F) %>% column_spec(1, bold = T) %>% collapse_rows(columns = 1, valign = "middle") t2=kable(table_df[c(25:47),], align = "c", row.names=FALSE) %>% kable_styling(full_width = F) %>% column_spec(1, bold = T) %>% collapse_rows(columns = 1, valign = "middle") paste(c('<table><tr valign="top"><td>', t1, '</td><td>', t2, '</td><tr></table>'), sep = '') %>% write_clip