Title: | Read and Convert Japanese Municipality Codes |
---|---|
Description: | Read Japanese city codes (<https://www.e-stat.go.jp/municipalities/cities>) to get city and prefecture names, or convert to city codes at different points in time. In addition, it merges or splits wards of designated cities and gets all city codes at a specific point in time. |
Authors: | Mizuki Uchida [aut, cre] |
Maintainer: | Mizuki Uchida <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2024-11-03 06:06:48 UTC |
Source: | https://github.com/uchidamizuki/jpcity |
Get city codes
city_code(city)
city_code(city)
city |
A |
A character
vector of city codes.
Convert to cities at different points in time
city_convert(city, from, to)
city_convert(city, from, to)
city |
A |
from |
A |
to |
A |
A list of a jpcity_city
object.
city <- parse_city(c("01201", "01202")) city_convert(city, from = "1970-04-01", to = "2020-01-01")
city <- parse_city(c("01201", "01202")) city_convert(city, from = "1970-04-01", to = "2020-01-01")
Get city data
city_data(city)
city_data(city)
city |
A |
A data frame.
Merge designated city wards
city_desig_merge(city, merge_tokyo = FALSE)
city_desig_merge(city, merge_tokyo = FALSE)
city |
A |
merge_tokyo |
Whether to merge Tokyo special wards? |
A jpcity_city
object.
city <- parse_city(c("01101", "13101")) city_desig_merge(city) city_desig_merge(city, merge_tokyo = TRUE)
city <- parse_city(c("01101", "13101")) city_desig_merge(city) city_desig_merge(city, merge_tokyo = TRUE)
Split designated cities into wards
city_desig_split(city, split_tokyo = TRUE)
city_desig_split(city, split_tokyo = TRUE)
city |
A |
split_tokyo |
Whether to split into Tokyo special wards? |
A list of a jpcity_city
object.
city <- parse_city(c("01100", "13100")) city_desig_split(city) city_desig_split(city, split_tokyo = FALSE)
city <- parse_city(c("01100", "13100")) city_desig_split(city) city_desig_split(city, split_tokyo = FALSE)
Get city duration
city_interval(city, intersect = FALSE)
city_interval(city, intersect = FALSE)
city |
A |
intersect |
Whether to get the common part of the duration of cities. |
A interval
vector of the duration of cities.
Get city names
city_name(city, type = c("city_desig", "city"), sep = "", kana = FALSE)
city_name(city, type = c("city_desig", "city"), sep = "", kana = FALSE)
city |
A |
type |
Types of city names. By default, returns both designated city
names ( |
sep |
Separator for city names. |
kana |
Whether to use hiragana or not? |
A character
vector of city names.
Convert city to prefecture
city_to_pref(city)
city_to_pref(city)
city |
A |
A jpcity_pref
object.
Find cities by string patterns
find_city(patterns, when = NULL)
find_city(patterns, when = NULL)
patterns |
Patterns to look for. If multiple patterns are given, find the cities that match all patterns. |
when |
A |
A jpcity_city
object.
Get cities at a specific point in time
get_city(when)
get_city(when)
when |
A |
A jpcity_city
object.
get_city("2020-01-01")
get_city("2020-01-01")
Test if the object is a jpcity_city object
is_city(x)
is_city(x)
x |
An object. |
TRUE
if the object inherits from the jpcity_city
class.
Check if a city is a designated city or a ward of a designated city
is_city_desig(x, type = "city")
is_city_desig(x, type = "city")
x |
A |
type |
A character vector of city types, |
A logical vector.
Test if the object is a jpcity_pref object
is_pref(x)
is_pref(x)
x |
An object. |
TRUE
if the object inherits from the jpcity_pref
class.
Parse city codes
parse_city(x, when = NULL, na = c("", "NA"))
parse_city(x, when = NULL, na = c("", "NA"))
x |
A |
when |
A |
na |
A |
A jpcity_city
object.
Parse prefecture codes or names
parse_pref(x, strict = TRUE)
parse_pref(x, strict = TRUE)
x |
A |
strict |
A scalar logical. Whether to require the code to have 1 or 2
digits. By default, |
A jpcity_pref
object.
Get prefecture codes
pref_code(city)
pref_code(city)
city |
A |
A integer vector of prefecture codes.
Get pref data
pref_data(pref)
pref_data(pref)
pref |
A |
A data frame.
Get prefecture names
pref_name(city)
pref_name(city)
city |
A |
A character
vector of prefecture names.