plu v0.1.1

0

Monthly downloads

0th

Percentile

Pluralize Phrases

Converts English phrases to singular or plural form based on the length of an associated vector. Contains helper functions to create natural language lists from vectors and to include the length of a vector in natural language.

Readme

plu

License:
MIT R build
status Dependencies

Pluralize phrases in R

Overview

plu provides a simplified way to dynamically generate plain-language messages in R when we can’t know beforehand whether a message will be singular or plural.

Pluralizes English phrases based on the length of an associated vector. Contains helper functions to create natural language lists from vectors and to include the length of a vector in natural language.

Installation

You can install the stable release of plu from CRAN with:

install.packages("plu")

You can install the development version of plu from GitHub with:

# install.packages("remotes")
remotes::install_github("rossellhayes/plu")

Usage

formulas1 <- c(x %in% 1:3 ~ "low", x %in% 4:6 ~ "medium", "x %in% 7:9")
formulas2 <- c(x %in% 1:3 ~ "low", x %in% 4:6 ~ "medium", "x %in% 7:9", "high")
problems1 <- Filter(function(x) !rlang::is_formula(x), formulas1)
problems2 <- Filter(function(x) !rlang::is_formula(x), formulas2)

paste(
  "All arguments must be formulas.",
  plu::ral("Argument", problems1), 
  plu::stick(problems1),
  plu::ral("isn't a formula.", problems1)
)
#> [1] "All arguments must be formulas. Argument x %in% 7:9 isn't a formula."

paste(
  "All arguments must be formulas.",
  plu::ral("Argument", problems2), 
  plu::stick(problems2, usethis::ui_code),
  plu::ral("isn't a formula.", problems2)
)
#> [1] "All arguments must be formulas. Arguments `x %in% 7:9` and `high` aren't formulas."

Credits

Hex sticker font is Bodoni* by indestructible type*.

Image adapted from icon made by Freepik from flaticon.com.


Please note that the plu project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Functions in plu

Name Description
plu_ralize Pluralize a word
plu-package plu: Pluralize Phrases
plu_ral Pluralize a phrase based on the length of a vector
plu_stick Collapse character vectors into natural language strings
No Results!

Last month downloads

Details

Type Package
License MIT + file LICENSE
URL https://github.com/rossellhayes/plu
BugReports https://github.com/rossellhayes/plu/issues
Encoding UTF-8
Language en-US
LazyData true
RoxygenNote 7.1.1
NeedsCompilation no
Packaged 2020-09-03 06:21:01 UTC; Alex
Repository CRAN
Date/Publication 2020-09-03 06:30:02 UTC
suggests covr , nombre , testthat
depends R (>= 2.10)
Contributors

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/plu)](http://www.rdocumentation.org/packages/plu)