Title: | Translate Integers into English |
---|---|
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". |
Authors: | John Fox, Bill Venables, Anthony Damico and Anne Pier Salverda |
Maintainer: | Bill Venables <[email protected]> |
License: | GPL-2 |
Version: | 1.2-6 |
Built: | 2025-01-03 07:10:59 UTC |
Source: | CRAN |
Converts numerical vectors into object that display as English words
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, ...)
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, ...)
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? |
A numerical object that can be printed as English words, or coerced to character as English words
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")
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")
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".
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, ...)
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, ...)
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)? |
A character string vector with an article prepended, either capitalized or not.
indefinite(1:12) paste0(Indefinite(1:12, FALSE), "-stage process") cat(paste(Indefinite(ordinal(1:10)), " point is ...\n", sep = ""))
indefinite(1:12) paste0(Indefinite(1:12, FALSE), "-stage process") cat(paste(Indefinite(ordinal(1:10)), " point is ...\n", sep = ""))
Allows arithmetic operations on "english"
class objects. To make sense
the operation should return an integer value.
## S3 method for class 'english' Ops(e1, e2)
## S3 method for class 'english' Ops(e1, e2)
e1 |
Numeric vector of object of class |
e2 |
Numeric vector of object of class |
Numeric vector of class "english"
english(1:10)^2 + 1:10 english(100) + (-5):5
english(1:10)^2 + 1:10 english(100) + (-5):5
Generates character strings of the ordinal version of numbers in English words.
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, ...)
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, ...)
x |
A numeric vector, usually integer, or an object of class "ordinal" |
... |
Ignored. Included only for compatibility. |
A character string vector of ordinal versions of the number, with S3 class "ordinal"
ordinal(1:12)
ordinal(1:12)
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.
words(x) Words(x)
words(x) Words(x)
x |
A numeric vector, usually integer |
A character string vector with the numbers expressed in English words.
cat("The Duke of York had ", words(10006), " men.\n", sep = "") cat("How many did he have? ", Words(10006), ".\n", sep = "")
cat("The Duke of York had ", words(10006), " men.\n", sep = "") cat("How many did he have? ", Words(10006), ".\n", sep = "")