conversion {cnum}R Documentation

Chinese Numerals Conversion

Description

Functions to convert between Chinese and Arabic numerals.

Usage

c2num(
  x,
  lang = default_cnum_lang(),
  mode = "casual",
  financial = FALSE,
  literal = FALSE
)

num2c(
  x,
  lang = default_cnum_lang(),
  mode = "casual",
  financial = FALSE,
  literal = FALSE,
  single = FALSE
)

Arguments

x

the Arabic/Chinese numerals to be converted, or a vector of them. The absolute value must not be greater than 1e+18.

lang

the language of the Chinese numerals. "tc" for Traditional Chinese. "sc" for Simplified Chinese. The default is "tc", but this can be changed by setting options(cnum.lang = "sc").

mode

the scale naming system to be enforced. See the ‘Details’ section for the list of supported modes.

financial

logical: should the financial numerals be used (daxie shuzi)?

literal

logical: should the numerals be converted literally? (e.g. 721 to be converted to "qi er yi" instead of "qibai ershiyi" and vice versa)

single

logical: should the return result with one scale character only? (e.g. 1.5e+08 as "yi dian wuyi" instead of "yiyi wuqianwan")

Value

c2num returns a numeric vector.

num2c returns a character vector.

Functions

Details

The following scale naming systems are supported:

Warnings

The modes "casual" and "casualPRC" implements a “myriad scale” with an interval of 1e+04 for large numbers, i.e. "yi" is 10,000 times of "wan", which is different from some of the interval systems used in ancient Chinese writings.

This package supports conversion of numbers with absolute value not greater than 1e+18. Note that numbers in R are in double precision that carries approximately 16 significant digits. The conversion accuracy for numbers beyond this limit is therefore not guaranteed.

References

The standard for mode "SIprefix" Names, Definitions and Symbols of the Legal Units of Measurement and the Decimal Multiples and Submultiples is available from https://gazette.nat.gov.tw/egFront/detail.do?metaid=108965 (in Traditional Chinese).

The standard for mode "SIprefixPRC" China Statutory Measurement Units is available from http://gkml.samr.gov.cn/nsjg/jls/201902/t20190225_291134.html (in Simplified Chinese).

See Also

Functions for detetction and extraction

Examples

c2num("EXAMPLE CHECK")

num2c(721)
num2c(-6)
num2c(3.14)
num2c(721, literal = TRUE)
num2c(1.45e12, financial = TRUE)
num2c(6.85e12, lang = "sc", mode = "casualPRC")
num2c(1.5e9, mode = "SIprefix", single = TRUE)


[Package cnum version 0.1.3 Index]