Package 'jpcity'

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

Help Index


Get city codes

Description

Get city codes

Usage

city_code(city)

Arguments

city

A jpcity_city object.

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 jpcity_city object.

from

A character (year, month, and day components) or date-time object of the starting date.

to

A character (year, month, and day components) or date-time object of the ending date.

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 jpcity_city object.

Value

A data frame.


Merge designated city wards

Description

Merge designated city wards

Usage

city_desig_merge(city, merge_tokyo = FALSE)

Arguments

city

A jpcity_city object.

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 jpcity_city object.

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 jpcity_city object.

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 jpcity_city object.

type

Types of city names. By default, returns both designated city names ("city_desig") and city names ("city").

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 jpcity_city object.

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 character (year, month, and day components) or date-time object.

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 character (year, month, and day components) or date-time object.

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 jpcity_city object.

type

A character vector of city types, "city" or "ward". By default, "city".

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 character vector of city codes.

when

A character (year, month, and day components) or date-time object.

na

A character vector to be treated as missing values.

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 character vector of prefecture codes or names.

strict

A scalar logical. Whether to require the code to have 1 or 2 digits. By default, TRUE.

Value

A jpcity_pref object.


Get prefecture codes

Description

Get prefecture codes

Usage

pref_code(city)

Arguments

city

A jpcity_city or jpcity_pref object.

Value

A integer vector of prefecture codes.


Get pref data

Description

Get pref data

Usage

pref_data(pref)

Arguments

pref

A jpcity_pref object.

Value

A data frame.


Get prefecture names

Description

Get prefecture names

Usage

pref_name(city)

Arguments

city

A jpcity_city object.

Value

A character vector of prefecture names.