-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
README.Rmd
205 lines (146 loc) · 4.58 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# zipangu <img src="man/figures/logo.png" align="right" width="120px" />
<!-- badges: start -->
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![CRAN\_Status\_Badge](https://badges.cranchecks.info/worst/zipangu.svg)](https://cran.r-project.org/package=zipangu)
[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/zipangu?color=FF5254)](https://cran.r-project.org/package=zipangu) [![minimal R version](https://img.shields.io/badge/R%3E%3D-3.2.0-blue.svg)](https://cran.r-project.org/)
[![Codecov test coverage](https://codecov.io/gh/uribo/zipangu/branch/master/graph/badge.svg)](https://app.codecov.io/gh/uribo/zipangu?branch=master)
[![R-CMD-check](https://github.com/uribo/zipangu/workflows/R-CMD-check/badge.svg)](https://github.com/uribo/zipangu/actions)
<!-- badges: end -->
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:
``` r
install.packages("zipangu")
```
and also, the developmment version from GitHub
``` r
install.packages("remotes")
remotes::install_github("uribo/zipangu")
```
## API
```{r}
library(zipangu)
```
### Address
```{r}
separate_address("東京都千代田区大手町一丁目")
```
Applied to data frame.
```{r, warning=FALSE}
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
```{r}
read_zipcode(system.file("zipcode_dummy/13TOKYO_oogaki.CSV", package = "zipangu"), "oogaki")
```
You can also load a file directly by specifying a URL.
```{r, eval = FALSE, echo = TRUE}
read_zipcode("https://www.post.japanpost.jp/zipcode/dl/jigyosyo/zip/jigyosyo.zip")
```
Utilities
```{r}
is_zipcode(7000027)
is_zipcode("700-0027")
zipcode_spacer("305-0053")
zipcode_spacer("305-0053", remove = TRUE)
is_prefecture("東京都")
```
### Calendar
#### Year (Japanese imperial year)
```{r}
convert_jyear("R1")
```
### Date
```{r}
convert_jdate("平成元年11月25日")
```
#### Public holidays in Japan
Given a year and holiday name as input, returns the date.
```{r}
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.
```{r}
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()`.
```{r}
jholiday(2022, lang = "jp")
```
Use `is_jholiday()` function to evaluate whether today is a holiday.
```{r}
is_jholiday("2022-01-10")
is_jholiday("2022-02-23")
```
### Convert
#### Hiragana to Katakana and more...
```{r}
str_jconv("アイウエオ",
str_conv_hirakana, to = "hiragana")
str_conv_zenhan("ガッ", "zenkaku")
str_conv_romanhira("aiueo", "hiragana")
```
#### Kansuji
```{r}
kansuji2arabic(c("一", "百"))
kansuji2arabic_all("北海道札幌市中央区北一条西二丁目")
```
#### Prefecture name
```{r}
harmonize_prefecture_name(
c("東京都", "北海道", "沖縄県"),
to = "short")
harmonize_prefecture_name(
c("東京", "北海道", "沖縄"),
to = "long")
```
### Label
```{r, echo=TRUE, eval=FALSE}
library(scales)
library(ggplot2)
theme_set(theme_bw(base_family = "IPAexGothic"))
demo_continuous(c(1, 1e9), label = label_kansuji())
```
```{r, echo=FALSE, eval=FALSE}
ggsave("man/figures/readme_demo_label_kansuji.png",
last_plot(),
width = 6,
height = 2)
```
![](man/figures/readme_demo_label_kansuji.png)
```{r, eval=FALSE, echo=TRUE}
demo_continuous(c(1, 1e9), label = label_kansuji_suffix())
```
```{r, echo=FALSE, eval=FALSE}
ggsave("man/figures/readme_demo_label_kansuji_suffix.png",
last_plot(),
width = 6,
height = 2)
```
![](man/figures/readme_demo_label_kansuji_suffix.png)
### Data set
```{r}
jpnprefs
```
### Kana (hiragana and katakana)
```{r}
kana(type = "hira")
kana(type = "hira", core = FALSE, historical = TRUE)
kana(type = "kata", dakuon = TRUE, handakuon = TRUE, kogaki = TRUE)
```