Type: | Package |
Title: | Read and Convert Japanese Municipality Codes |
Version: | 0.3.0 |
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. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Depends: | R (≥ 4.1) |
Imports: | cli, dplyr, lifecycle, lubridate, pillar, purrr, rlang, stringr, tibble, vctrs |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
URL: | https://uchidamizuki.github.io/jpcity/, https://github.com/UchidaMizuki/jpcity |
BugReports: | https://github.com/UchidaMizuki/jpcity/issues |
NeedsCompilation: | no |
Packaged: | 2024-10-04 14:14:53 UTC; uchid |
Author: | Mizuki Uchida [aut, cre] |
Maintainer: | Mizuki Uchida <uchidamizuki@vivaldi.net> |
Repository: | CRAN |
Date/Publication: | 2024-10-04 14:30:02 UTC |
jpcity: 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.
Author(s)
Maintainer: Mizuki Uchida uchidamizuki@vivaldi.net
See Also
Useful links:
Report bugs at https://github.com/UchidaMizuki/jpcity/issues
Get city codes
Description
Get city codes
Usage
city_code(city)
Arguments
city |
A |
Value
A character
vector of city codes.
Convert to cities at different points in time
Description
Convert to cities at different points in time
Usage
city_convert(city, from, to)
Arguments
city |
A |
from |
A |
to |
A |
Value
A list of a jpcity_city
object.
Examples
city <- parse_city(c("01201", "01202"))
city_convert(city,
from = "1970-04-01",
to = "2020-01-01")
Get city data
Description
Get city data
Usage
city_data(city)
Arguments
city |
A |
Value
A data frame.
Merge designated city wards
Description
Merge designated city wards
Usage
city_desig_merge(city, merge_tokyo = FALSE)
Arguments
city |
A |
merge_tokyo |
Whether to merge Tokyo special wards? |
Value
A jpcity_city
object.
Examples
city <- parse_city(c("01101", "13101"))
city_desig_merge(city)
city_desig_merge(city,
merge_tokyo = TRUE)
Split designated cities into wards
Description
Split designated cities into wards
Usage
city_desig_split(city, split_tokyo = TRUE)
Arguments
city |
A |
split_tokyo |
Whether to split into Tokyo special wards? |
Value
A list of a jpcity_city
object.
Examples
city <- parse_city(c("01100", "13100"))
city_desig_split(city)
city_desig_split(city,
split_tokyo = FALSE)
Get city duration
Description
Get city duration
Usage
city_interval(city, intersect = FALSE)
Arguments
city |
A |
intersect |
Whether to get the common part of the duration of cities. |
Value
A interval
vector of the duration of cities.
Get city names
Description
Get city names
Usage
city_name(city, type = c("city_desig", "city"), sep = "", kana = FALSE)
Arguments
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? |
Value
A character
vector of city names.
Convert city to prefecture
Description
Convert city to prefecture
Usage
city_to_pref(city)
Arguments
city |
A |
Value
A jpcity_pref
object.
Find cities by string patterns
Description
Find cities by string patterns
Usage
find_city(patterns, when = NULL)
Arguments
patterns |
Patterns to look for. If multiple patterns are given, find the cities that match all patterns. |
when |
A |
Value
A jpcity_city
object.
Get cities at a specific point in time
Description
Get cities at a specific point in time
Usage
get_city(when)
Arguments
when |
A |
Value
A jpcity_city
object.
Examples
get_city("2020-01-01")
Test if the object is a jpcity_city object
Description
Test if the object is a jpcity_city object
Usage
is_city(x)
Arguments
x |
An object. |
Value
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
Description
Check if a city is a designated city or a ward of a designated city
Usage
is_city_desig(x, type = "city")
Arguments
x |
A |
type |
A character vector of city types, |
Value
A logical vector.
Test if the object is a jpcity_pref object
Description
Test if the object is a jpcity_pref object
Usage
is_pref(x)
Arguments
x |
An object. |
Value
TRUE
if the object inherits from the jpcity_pref
class.
Parse city codes
Description
Parse city codes
Usage
parse_city(x, when = NULL, na = c("", "NA"))
Arguments
x |
A |
when |
A |
na |
A |
Value
A jpcity_city
object.
Parse prefecture codes or names
Description
Parse prefecture codes or names
Usage
parse_pref(x, strict = TRUE)
Arguments
x |
A |
strict |
A scalar logical. Whether to require the code to have 1 or 2
digits. By default, |
Value
A jpcity_pref
object.
Get prefecture codes
Description
Get prefecture codes
Usage
pref_code(city)
Arguments
city |
A |
Value
A integer vector of prefecture codes.
Get pref data
Description
Get pref data
Usage
pref_data(pref)
Arguments
pref |
A |
Value
A data frame.
Get prefecture names
Description
Get prefecture names
Usage
pref_name(city)
Arguments
city |
A |
Value
A character
vector of prefecture names.