uribo / jpndistrict

🗾 Create Japansese Administration Area Maps
http://uribo.github.io/jpndistrict
Other
22 stars 3 forks source link

Added City code historical modified dataset #23

Closed uribo closed 5 years ago

uribo commented 5 years ago

Summary

総務省の市町村合併情報ページより、データをダウンロード。 平成17年4月1日以降の市区町村コード改正情報を整理した (内部利用のデータとして)。

市町村コードの検証用に2つの関数を追加。いずれもun-export

find_jis_code(33, "倉敷市")
## [1] "33202"
find_jis_code(14, c("鎌倉市", "小田原市"), strict = FALSE)
## [1] "33202"

cityname_reform("岡山市北区")
## [1] "岡山市 北区"
cityname_reform("勝田郡勝央町")
## [1] "勝田郡 勝央町"

Related Issues

22 ... cityname_reform() を適用させれば解決なはず

Additional Information

devtools::load_all()
library(dplyr)
library(lubridate)

citycode_sets <- 
  readRDS(system.file("extdata/citycode_sets.rds", package = "jpndistrict"))

glimpse(citycode_sets)
## Observations: 1,436
## Variables: 6
## $ date             <date> 2005-04-01, 2005-04-01, 2005-04-01, 2005-04-01, 2005-04-01, 2005-04-01, 2005-04-01, 2005-04-01, 2005...
## $ before_code      <chr> "01344", "01345", "02364", "02201", "04561", "04563", "04564", "04565", "04567", "04582", "04202", "0...
## $ before_city_name <chr> "砂原町", "森町", "浪岡町", "青森市", "河北町", "雄勝町", "河南町", "桃生町", "北上町", "牡鹿町", "石巻市", "迫町", "登米町", "東和町", "中田町"...
## $ after_code       <chr> "01345", "01345", "02201", "02201", "04202", "04202", "04202", "04202", "04202", "04202", "04202", "0...
## $ after_city_name  <chr> "森町", "森町", "青森市", "青森市", "石巻市", "石巻市", "石巻市", "石巻市", "石巻市", "石巻市", "石巻市", "登米市", "登米市", "登米市", "登米市"...
## $ .id              <dbl> 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6,...

d <- 
  citycode_sets %>% 
  mutate(fy = substr(semester(date, with_year = TRUE), 1, 4))

library(ggplot2)
d %>% 
  distinct(.id, .keep_all = TRUE) %>% 
  count(fy) %>% 
  ggplot(aes(fy, n)) +
  geom_bar(stat = "identity") +
  labs(x = "Physical Year",
       title = "Modified cities since 2005")

image