Type: | Package |
Title: | Translate Integers into English |
Version: | 1.2-6 |
Date: | 2021-08-21 |
Author: | John Fox, Bill Venables, Anthony Damico and Anne Pier Salverda |
Maintainer: | Bill Venables <Bill.Venables@gmail.com> |
Description: | Allow numbers to be presented in an English language version, one, two, three, ... Ordinals are also available, first, second, third, ... and indefinite article choice, "a" or "an". |
Suggests: | utils, knitr, rmarkdown |
License: | GPL-2 |
LazyLoad: | yes |
NeedsCompilation: | no |
Encoding: | UTF-8 |
RoxygenNote: | 7.1.1 |
VignetteBuilder: | knitr |
Packaged: | 2021-08-21 06:16:24 UTC; bill |
Repository: | CRAN |
Date/Publication: | 2021-08-21 06:40:02 UTC |
English Arithmetic
Description
Allows arithmetic operations on "english"
class objects. To make sense
the operation should return an integer value.
Usage
## S3 method for class 'english'
Ops(e1, e2)
Arguments
e1 |
Numeric vector of object of class |
e2 |
Numeric vector of object of class |
Value
Numeric vector of class "english"
Examples
english(1:10)^2 + 1:10
english(100) + (-5):5
"_PACKAGE" Numbers in Englis Words
Description
Converts numerical vectors into object that display as English words
Usage
as.english(x, ...)
english(x, ...)
## Default S3 method:
english(x, ...)
## S3 method for class 'numeric'
english(x, UK, ...)
## S3 method for class 'english'
as.numeric(x, ...)
## S3 method for class 'english'
print(x, ...)
## S3 method for class 'english'
rep(x, ...)
## S3 method for class 'english'
x[i]
## S3 method for class 'english'
format(x, ...)
## S3 method for class 'english'
as.character(x, ...)
## S3 method for class 'english'
sort(x, decreasing = FALSE, ...)
Arguments
x |
A numerical vector, usually integer. |
... |
Additional arguments passed on, currently mostly ignored |
UK |
Logical, Use the UK (English) style (TRUE) or the USA (American) style (FALSE).
The default can be set as |
i |
Index vector of any kind |
decreasing |
Logical: should the sorting be in decreasing order? |
Value
A numerical object that can be printed as English words, or coerced to character as English words
Examples
english(10000) + (-5):5
set.seed(123)
(jumble <- english(sample(1:20)))
sort(jumble)
(x <- english(sample(1:100, 10)))
sort(x)
toupper(english(1:10))
## For mothers of small children:
cat(paste("This is the", ordinal(1:5), "time I've told you!"), sep = "\n")
Add Indefinite Article
Description
Adds an initial indefinite article "a" or "an" to a numerical
object expressed either as digits or as words in the result.
The capitalized form, Initial
, capitalizes the initial
letter: "An" or "A".
Usage
indefinite(n, ...)
## S3 method for class 'numeric'
indefinite(n, words = TRUE, ...)
## S3 method for class 'english'
indefinite(n, words = TRUE, ...)
## S3 method for class 'ordinal'
indefinite(n, ...)
## S3 method for class 'character'
indefinite(n, ...)
Indefinite(n, ...)
Arguments
n |
either a numeric vector or a ordinal character string. |
... |
Extra arguments, currently ignored |
words |
logical: should the numbers be expressed as words (TRUE) or digits (FALSE)? |
Value
A character string vector with an article prepended, either capitalized or not.
Examples
indefinite(1:12)
paste0(Indefinite(1:12, FALSE), "-stage process")
cat(paste(Indefinite(ordinal(1:10)), " point is ...\n", sep = ""))
Ordinal Numbers
Description
Generates character strings of the ordinal version of numbers in English words.
Usage
ordinal(x, ...)
## S3 method for class 'english'
ordinal(x, ...)
## S3 method for class 'numeric'
ordinal(x, ...)
## S3 method for class 'character'
ordinal(x, ...)
## S3 method for class 'ordinal'
print(x, ...)
Arguments
x |
A numeric vector, usually integer, or an object of class "ordinal" |
... |
Ignored. Included only for compatibility. |
Value
A character string vector of ordinal versions of the number, with S3 class "ordinal"
Examples
ordinal(1:12)
Express Numbers in Words
Description
Convert numerical objects to Enghish character strings.
A convenience function for use mainly with RMarkdown
in-text inserts. The capitalized version, Words
,
makes the initial letter of the result upper case.
Usage
words(x)
Words(x)
Arguments
x |
A numeric vector, usually integer |
Value
A character string vector with the numbers expressed in English words.
Examples
cat("The Duke of York had ", words(10006), " men.\n", sep = "")
cat("How many did he have? ", Words(10006), ".\n", sep = "")