pluralise: Pluralise words depending on a value

View source: R/pluralise.R

pluraliseR Documentation

Pluralise words depending on a value

Description

This function takes a given value and outputs whether a word needs to be pluralised based on the value of the input: if the value is 1, the output is not pluralised, if the value is > 1, the output is pluralised. The function can either pluralise a specific input word, or the output be used next to an existing word (if the word parameter is left blank). NB - this function simply adds an 's' to pluralise; for more complex pluralisations (e.g. 'ies' rather than 'ys') this function will not provide desired output.

Usage

pluralise(value, word = "")

Arguments

value

the integer value preceeding your word which needs to be checked for if pluralisation is required

word

the word that you wish to pluralise. Optional, defaults to blank - if blank, the function outputs an 's' (if pluralisation required) to add to the end of an existing word

Examples

pluralise(4, "percentage point") # outputs string "percentage points"
pluralise(1, "week") # outputs string "week"
pluralise(2) # outputs string "s"
pluralise(1) # outputs blank string ""
pluralise(-5, "week") # outputs string "weeks"


moj-analytical-services/mojrap documentation built on July 30, 2023, 4:43 p.m.