Nippon: Japanese utility functions and data

日本語ユーザーのための便利な関数とデータセット

> library(Nippon)
Loading required package: maptools
Loading required package: sp
Checking rgeos availability: TRUE
> data("month.name.jp")
> data("prefectures")

バージョン: 0.6.3.1


関数名 概略
JapanPrefecturesMap A simple choropleth map of Japan
JapaneseColors Find RGB by Japanese color names
Nippon-internal Internal objects in the Nippon package
Nippon-package Japanese utility functions and data
jholiday Calculate public holidays in Japan
jyear Conversion to Japanese year style
kakasi Interface to kakasi
kana2roma Romanization of Japanese
kata2hira Conversion form Katakana to Hiragana
month.name.jp The Japanese name of months
nippon.palette Switch the color palette to JIS colors
prefectures Prefectural names in Japan
sjis2utf8 Wrapper of iconv for Japanese encoding
zen2han Convert Japanese characters from fullwidth (zenkaku) to halfwidth (hankaku) forms

JapanPrefecturesMap

日本の都道府県別塗り分け図の描画

Arguments

  • col
  • inset... 沖縄県を正確な位置で表示しないかどうか
> op <- par(bg = "skyblue")
> JapanPrefecturesMap(col = gray.colors(8), axes = FALSE, inset = TRUE)

jyear

西暦(4桁の数字)を和暦表記にする

Arguments

  • x
  • shift
  • withAD
  • ascii
> jyear(2000, 
+       ascii = TRUE)
[1] "H12"
> jyear(1989, 
+       ascii  = TRUE,
+       withAD = TRUE)
[1] "H1(1989)"
> jyear(1989,
+       ascii = FALSE,
+       shift = TRUE)
[1] "昭和64年"

sjis2utf8

> iconv(zenkaku$upper, from = "UTF-8", to = "CP932") %>% sjis2utf8()
[1] "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

kakasi

> kakasi("あいうえお")
あいうえお 
   "aiueo"

kana2roma

日本語のローマ字表記

> c(hiragana()[21:25], katakana()[26:30]) %>% kana2roma(.)
 [1] "sa"  "za"  "shi" "ji"  "su"  "zu"  "se"  "ze"  "so"  "zo"

kata2hira

片仮名と平仮名の相互変換

> katakana()[26:30]
[1] "ズ" "セ" "ゼ" "ソ" "ゾ"
> kata2hira(katakana()[26:30])
[1] "ず" "せ" "ぜ" "そ" "ぞ"
> hiragana()[21:25]
[1] "さ" "ざ" "し" "じ" "す"
> hira2kata(hiragana()[21:25])
[1] "サ" "ザ" "シ" "ジ" "ス"

prefectures

日本の都道府県およびそのコード番号

> data("prefectures")
> prefectures %>% {
+   print(dim(.))
+   dplyr::tbl_df(.)
+ }
[1] 47  3
Source: local data frame [47 x 3]

   jiscode   name region
     <chr>  <chr>  <chr>
1       01 北海道 北海道
2       02 青森県   東北
3       03 岩手県   東北
4       04 宮城県   東北
5       05 秋田県   東北
6       06 山形県   東北
7       07 福島県   東北
8       08 茨城県   関東
9       09 栃木県   関東
10      10 群馬県   関東
..     ...    ...    ...

zen2han

全角英数字を半角英数字に変換する

> c("0", "F") %>% zen2han()
Warning in if (Encoding(s) != "UTF-8") s <- iconv(s, from = "", to =
"UTF-8"): the condition has length > 1 and only the first element will be
used
[1] "0F"

zenkaku

> zenkaku %>% {
+   print(class(.))
+   print(names(.))
+   dim(.)
+ }
[1] "list"
[1] "number" "lower"  "upper"
NULL