An open API service indexing awesome lists of open source software.

https://github.com/joeroe/numerals

R package for numeric vectors with Unicode numerals
https://github.com/joeroe/numerals

arabic-numerals bengali-numerals burmese-numerals numerals persian-numerals r r-package vctrs

Last synced: 3 months ago
JSON representation

R package for numeric vectors with Unicode numerals

Awesome Lists containing this project

README

        

---
output: github_document
---

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

# numerals

[![Project Status: Concept – Minimal or no implementation has been done yet, or the repository is only intended to be a limited example, demo, or proof-of-concept.](https://www.repostatus.org/badges/latest/concept.svg)](https://www.repostatus.org/#concept)
[![CRAN status](https://www.r-pkg.org/badges/version/numerals)](https://CRAN.R-project.org/package=numerals)
[![R-CMD-check](https://github.com/joeroe/numerals/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/joeroe/numerals/actions/workflows/R-CMD-check.yaml)

**numerals** is an R package that extends the base numeric types with methods for printing using Unicode digits in other numeral systems.
It currently supports Eastern Arabic (`"ar"`), Bengali (`"bn"`), Persian (`"fa"`), and Burmese (`"my"`) numerals.

## Installation

You can install the development version of numerals from GitHub using [devtools](https://devtools.r-lib.org/):

```r
# install.package("devtools")
devtools::install_github("joeroe/numerals")
```

numerals has not yet been released on CRAN.

## Usage

`numeral()` creates a numeric vector which is printed in another numeral system:

```{r eg-numerals}
library("numerals")
# Eastern Arabic numerals
numeral(1:10, "ar")

# Persian numerals
numeral(1:10, "fa")
```

Numerals are compatible with both base and tidyverse packages.
For example, they are printed in data frames and [tibbles](https://tibble.tidyverse.org/):

```{r eg-tibbles}
library("tibble")
x <- data.frame(en = 1:10, ar = numeral(1:10, "ar"), fa = numeral(1:10, "fa"))

x
as_tibble(x)
```

Otherwise, numerals are freely coercible to base numerics and so can be used in calculations:

```{r eg-calc}
numeral(2, "ar") * 10
```