knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

zipangu

Lifecycle: stable CRAN_Status_Badge CRAN RStudio mirror downloads minimal R version Codecov test coverage R-CMD-check

The goal of {zipangu} is to replace the functionality provided by the {Nippon} archived from CRAN. Add some functions to make it easier to treat data that address, year, Kanji and Kana.

Installation

You can install the released version of {zipangu} from CRAN with:

install.packages("zipangu")

and also, the developmment version from GitHub

install.packages("remotes")
remotes::install_github("uribo/zipangu")

API

library(zipangu)

Address

separate_address("東京都千代田区大手町一丁目")

Applied to data frame.

library(dplyr, warn.conflicts = FALSE)
data.frame(address = c("東京都千代田区大手町一丁目", "岡山県岡山市北区清心町16-13")) %>% 
  mutate(address_components = purrr::pmap(., ~ separate_address(..1))) %>% 
  tidyr::unnest_wider(col = address_components)

Zip-code

read_zipcode(system.file("zipcode_dummy/13TOKYO_oogaki.CSV", package = "zipangu"), "oogaki")

You can also load a file directly by specifying a URL.

read_zipcode("https://www.post.japanpost.jp/zipcode/dl/jigyosyo/zip/jigyosyo.zip")

Utilities

is_zipcode(7000027)
is_zipcode("700-0027")
zipcode_spacer("305-0053")
zipcode_spacer("305-0053", remove = TRUE)

is_prefecture("東京都")

Calendar

Year (Japanese imperial year)

convert_jyear("R1")

Date

convert_jdate("平成元年11月25日")

Public holidays in Japan

Given a year and holiday name as input, returns the date.

jholiday_spec(2022, "New Year's Day", lang = "en")

Holiday names can be specified in English ("en") and Japanese ("jp") by default, en is used.

jholiday_spec(2022, "Coming of Age Day", lang = "en")
jholiday_spec(2022, "\u6210\u4eba\u306e\u65e5", lang = "jp")

Check the list of holidays for a year with the jholiday().

jholiday(2022, lang = "jp")

Use is_jholiday() function to evaluate whether today is a holiday.

is_jholiday("2022-01-10")
is_jholiday("2022-02-23")

Convert

Hiragana to Katakana and more...

str_jconv("アイウエオ", 
          str_conv_hirakana, to = "hiragana")
str_conv_zenhan("ガッ", "zenkaku")
str_conv_romanhira("aiueo", "hiragana")

Kansuji

kansuji2arabic(c("一", "百"))
kansuji2arabic_all("北海道札幌市中央区北一条西二丁目")

Prefecture name

harmonize_prefecture_name(
  c("東京都", "北海道", "沖縄県"), 
  to = "short")
harmonize_prefecture_name(
  c("東京", "北海道", "沖縄"), 
  to = "long")

Label

library(scales)
library(ggplot2)
theme_set(theme_bw(base_family = "IPAexGothic"))
demo_continuous(c(1, 1e9), label = label_kansuji())
ggsave("man/figures/readme_demo_label_kansuji.png",
       last_plot(),
       width = 6,
       height = 2)

demo_continuous(c(1, 1e9), label = label_kansuji_suffix())
ggsave("man/figures/readme_demo_label_kansuji_suffix.png",
       last_plot(),
       width = 6,
       height = 2)

Data set

jpnprefs

Kana (hiragana and katakana)

kana(type = "hira")

kana(type = "hira", core = FALSE, historical = TRUE)

kana(type = "kata", dakuon = TRUE, handakuon = TRUE, kogaki = TRUE)


uribo/zipangu documentation built on Nov. 8, 2024, 10:25 p.m.