Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added City code historical modified dataset #23

Merged
merged 19 commits into from Nov 20, 2018
Merged

Conversation

@uribo
Copy link
Owner

@uribo uribo commented Nov 20, 2018

Summary

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

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

  • find_jis_code() : 都道府県コードと市町村名で正しい市町村コードを返却(変遷は考慮せず)
  • cityname_reform(): 市と区、郡と町・村表記での空白ルールを適用
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

@uribo uribo merged commit 34eb811 into master Nov 20, 2018
@uribo uribo deleted the feature-city_code_table branch Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.