【R】都道府県別 気温
2020年3月2日
総務省統計局が発表している「統計でみる都道府県のすがた2020」から、都道府県別の最高気温、最低気温を表示します。最高気温とは、日最高気温の月平均の最高値を、最低気温とは、日最低気温の月平均の最低値を言います。
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$都道府県, 最高気温=dat$最高気温, 最低気温=dat$最低気温)
datc_k <- cut(dat$最高気温, hist(dat$最高気温, 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$最低気温, hist(dat$最低気温, plot=FALSE)$breaks, right=FALSE)
datc_mcol <- rainbow(length(levels(datc_m)), start = col_start, end=col_end)[as.integer(datc_m)]
windowsFonts(JP4=windowsFont("Biz Gothic"))
windows(width=1600, height=800)
par(family="JP4")
layout(matrix(1:2, 1, 2))
library(NipponMap)
JapanPrefMap(datc_kcol, main="最高気温 (総務省統計局より) ")
legend("bottomright", fill=rainbow(length(levels(datc_k)), start = col_start, end=col_end), legend=names(table(datc_k)))
JapanPrefMap(datc_mcol, main="最低気温 (総務省統計局より) ")
legend("bottomright", fill=rainbow(length(levels(datc_m)), start = col_start, end=col_end), legend=names(table(datc_m)))
library(clipr)
kable(table_df, align = "c") %>%
kable_styling(full_width = F) %>%
column_spec(1, bold = T) %>%
collapse_rows(columns = 1, valign = "middle") %>%
write_clip

| 都道府県 | 最高気温 | 最低気温 |
|---|---|---|
| 北海道 | 25.7 | -7.6 |
| 青森 | 27.4 | -5.1 |
| 岩手 | 29.4 | -6.9 |
| 宮城 | 29.7 | -2.2 |
| 秋田 | 29.2 | -4.0 |
| 山形 | 32.8 | -4.7 |
| 福島 | 33.4 | -2.4 |
| 茨城 | 31.9 | -2.4 |
| 栃木 | 32.8 | -2.8 |
| 群馬 | 33.9 | -0.7 |
| 埼玉 | 34.5 | -1.2 |
| 千葉 | 32.2 | 1.8 |
| 東京 | 32.7 | 0.6 |
| 神奈川 | 32.2 | 2.1 |
| 新潟 | 31.7 | -1.6 |
| 富山 | 32.8 | -1.0 |
| 石川 | 32.9 | -0.1 |
| 福井 | 33.7 | -1.6 |
| 山梨 | 34.5 | -2.8 |
| 長野 | 32.8 | -4.6 |
| 岐阜 | 35.1 | -0.1 |
| 静岡 | 32.7 | 1.3 |
| 愛知 | 35.3 | 0.2 |
| 三重 | 33.2 | 1.2 |
| 滋賀 | 33.6 | -0.4 |
| 京都 | 35.0 | 0.4 |
| 大阪 | 34.6 | 1.8 |
| 兵庫 | 32.7 | 2.1 |
| 奈良 | 34.4 | -0.2 |
| 和歌山 | 33.2 | 1.9 |
| 鳥取 | 34.4 | -0.9 |
| 島根 | 33.7 | -0.7 |
| 岡山 | 34.7 | -0.9 |
| 広島 | 34.7 | 1.0 |
| 山口 | 35.2 | -0.9 |
| 徳島 | 33.1 | 1.5 |
| 香川 | 34.4 | 0.9 |
| 愛媛 | 34.4 | 1.7 |
| 高知 | 32.8 | 0.9 |
| 福岡 | 34.5 | 2.7 |
| 佐賀 | 35.3 | 1.0 |
| 長崎 | 33.6 | 2.5 |
| 熊本 | 35.6 | 0.5 |
| 大分 | 33.9 | 1.5 |
| 宮崎 | 31.6 | 2.4 |
| 鹿児島 | 33.6 | 3.7 |
| 沖縄 | 31.2 | 14.4 |