Skip to content

Commit

Permalink
prep for cran submission
Browse files Browse the repository at this point in the history
  • Loading branch information
bahadzie committed Jun 5, 2024
1 parent 92074e5 commit b1ed4d3
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
^\.Rproj\.user$
^CITATION\.cff$
^__.*$
^\.vscode.*
^\.vscode.*
^cran-comments\.md$
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: numberize
Title: Convert Words To Numbers In Multiple Languages
Version: 1.0.0
Title: Convert Words to Numbers in Multiple Languages
Version: 0.0.1
Authors@R: c(
person("Chris", "Hartgerink", , "[email protected]", role = "rev",
comment = c(ORCID = "0000-0003-1050-6809")),
Expand Down
4 changes: 0 additions & 4 deletions R/numberize.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Generate a numeric vector from text in a supported language.
#'
#' @param text Word(s) that spell numbers. e.g. "one", "deux", "trois"
#' @param lang The text's language. Currently one of `"en" | "fr" | "es"`.
#'
#' @return A numeric vector.
#' @keywords internal
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
digits_from <- function(text, lang = "en") {
invalid_structure <- function(positions) {
valid_position <- c(
Expand Down Expand Up @@ -134,7 +132,6 @@ digits_from <- function(text, lang = "en") {
numbers[match(words, numbers[[lang]]), "digit"]
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Generate a number from a numeric vector.
#' Uses `digits_from()` output to generate the numeric value of the text.
#'
Expand All @@ -143,7 +140,6 @@ digits_from <- function(text, lang = "en") {
#' @return A numeric value.
#'
#' @keywords internal
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
number_from <- function(digits) {
thousand_index <- match(1000, digits, nomatch = 0)
million_index <- match(1E6, digits, nomatch = 0)
Expand Down
24 changes: 15 additions & 9 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ knitr::opts_chunk$set(
# _{{ packagename }}_ <img src="man/figures/logo.svg" align="right" width="120" />

<!-- badges: start -->
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit)
[![R-CMD-check](https://github.com/{{ gh_repo }}/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/{{ gh_repo }}/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/{{ gh_repo }}/branch/main/graph/badge.svg)](https://app.codecov.io/gh/{{ gh_repo }}?branch=main)
[![lifecycle-{{ recon }}](https://www.reconverse.org/images/badge-{{ recon }}.svg)](https://www.reconverse.org/lifecycle.html#{{ recon }})
[![CRAN status](https://www.r-pkg.org/badges/version/{{ packagename }})](https://CRAN.R-project.org/package={{ packagename }})
<!-- [![CRAN status](https://www.r-pkg.org/badges/version/{{ packagename }})](https://CRAN.R-project.org/package={{ packagename }}) -->

<!-- badges: end -->

Expand All @@ -37,22 +37,28 @@ _{{ packagename }}_ is developed at the [{{ department }}]({{ department_url }})

## Installation

The package can be installed from CRAN using

```r
install.packages("{{packagename}}")
```

### Development version

You can install the development version of _{{ packagename }}_ from
[GitHub](https://github.com/) with:

```{r eval = FALSE}
pak::pak("{{ gh_repo }}")
```

```{r}
library("numberize")
```

## Example

These examples illustrate the current functionality.

```{r eval=TRUE}
library("numberize")
# numberize a French string
numberize("zéro", lang = "fr")
Expand All @@ -75,9 +81,9 @@ numberize(

## Related packages and Limitations
- [`{numberwang}`](https://github.com/coolbutuseless/numberwang) converts numbers to words and vice versa. Limitation: English only, not on CRAN.
- [`{nombre}`](https://cran.r-project.org/web/packages/nombre/index.html) converts numerics into words. Limitation: English only, no word to number conversion.
- [`{english}`](https://cran.r-project.org/web/packages/english/index.html) converts numerics into words. Limitation: English only, no word to number conversion.
- [`{spanish}`](https://cran.r-project.org/web/packages/spanish/index.html) converts numbers to words and vice versa. Limitation: Spanish only.
- [`{nombre}`](https://CRAN.R-project.org/package=nombre) converts numerics into words. Limitation: English only, no word to number conversion.
- [`{english}`](https://CRAN.R-project.org/package=english) converts numerics into words. Limitation: English only, no word to number conversion.
- [`{spanish}`](https://CRAN.R-project.org/package=spanish) converts numbers to words and vice versa. Limitation: Spanish only.

_{{ packagename }}_ is released as a standalone package in the hope that it will be useful to the R community at large. _{{ packagename }}_ was created in response to data cleaning requirements in [{cleanepi}](https://github.com/epiverse-trace/cleanepi).

Expand Down
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
<!-- badges: start -->

[![License:
MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit/)
MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit)
[![R-CMD-check](https://github.com/epiverse-trace/numberize/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/epiverse-trace/numberize/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/epiverse-trace/numberize/branch/main/graph/badge.svg)](https://app.codecov.io/gh/epiverse-trace/numberize?branch=main)
[![lifecycle-stable](https://www.reconverse.org/images/badge-stable.svg)](https://www.reconverse.org/lifecycle.html#stable)
[![CRAN
status](https://www.r-pkg.org/badges/version/numberize)](https://CRAN.R-project.org/package=numberize)
<!-- [![CRAN status](https://www.r-pkg.org/badges/version/numberize)](https://CRAN.R-project.org/package=numberize) -->

<!-- badges: end -->

Expand All @@ -40,22 +39,28 @@ at the London School of Hygiene and Tropical Medicine as part of the

## Installation

You can install the development version of *numberize* from
[GitHub](https://github.com/) with:
The package can be installed from CRAN using

``` r
pak::pak("epiverse-trace/numberize")
install.packages("numberize")
```

### Development version

You can install the development version of *numberize* from
[GitHub](https://github.com/) with:

``` r
library("numberize")
pak::pak("epiverse-trace/numberize")
```

## Example

These examples illustrate the current functionality.

``` r
library("numberize")

# numberize a French string
numberize("zéro", lang = "fr")
#> [1] 0
Expand Down Expand Up @@ -87,14 +92,14 @@ numberize(
- [`{numberwang}`](https://github.com/coolbutuseless/numberwang)
converts numbers to words and vice versa. Limitation: English only,
not on CRAN.
- [`{nombre}`](https://cran.r-project.org/web/packages/nombre/index.html)
converts numerics into words. Limitation: English only, no word to
number conversion.
- [`{english}`](https://cran.r-project.org/web/packages/english/index.html)
converts numerics into words. Limitation: English only, no word to
number conversion.
- [`{spanish}`](https://cran.r-project.org/web/packages/spanish/index.html)
converts numbers to words and vice versa. Limitation: Spanish only.
- [`{nombre}`](https://CRAN.R-project.org/package=nombre) converts
numerics into words. Limitation: English only, no word to number
conversion.
- [`{english}`](https://CRAN.R-project.org/package=english) converts
numerics into words. Limitation: English only, no word to number
conversion.
- [`{spanish}`](https://CRAN.R-project.org/package=spanish) converts
numbers to words and vice versa. Limitation: Spanish only.

*numberize* is released as a standalone package in the hope that it will
be useful to the R community at large. *numberize* was created in
Expand Down
5 changes: 5 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
2 changes: 1 addition & 1 deletion tests/spelling.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ if (requireNamespace("spelling", quietly = TRUE)) {
spelling::spell_check_test(
vignettes = TRUE,
error = TRUE,
skip_on_cran = FALSE
skip_on_cran = TRUE
)
}

0 comments on commit b1ed4d3

Please sign in to comment.