as.english.RdConverts 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, ...)A numerical vector, usually integer.
Additional arguments passed on, currently mostly ignored
Logical, Use the UK (English) style (TRUE) or the USA (American) style (FALSE).
The default can be set as options(english.UK = TRUE); if unset, a suitable
style is guessed from the user's current locale.
Index vector of any kind
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
#> [1] nine thousand nine hundred ninety-five
#> [2] nine thousand nine hundred ninety-six
#> [3] nine thousand nine hundred ninety-seven
#> [4] nine thousand nine hundred ninety-eight
#> [5] nine thousand nine hundred ninety-nine
#> [6] ten thousand
#> [7] ten thousand one
#> [8] ten thousand two
#> [9] ten thousand three
#> [10] ten thousand four
#> [11] ten thousand five
set.seed(123)
(jumble <- english(sample(1:20)))
#> [1] fifteen nineteen fourteen three ten two six
#> [8] eleven five four eighteen nine twenty seventeen
#> [15] twelve seven sixteen one eight thirteen
sort(jumble)
#> [1] one two three four five six seven
#> [8] eight nine ten eleven twelve thirteen fourteen
#> [15] fifteen sixteen seventeen eighteen nineteen twenty
(x <- english(sample(1:100, 10)))
#> [1] nine ninety-three seventy-two twenty-six seven
#> [6] forty-two one hundred eighty-three thirty-six seventy-eight
sort(x)
#> [1] seven nine twenty-six thirty-six forty-two
#> [6] seventy-two seventy-eight eighty-three ninety-three one hundred
toupper(english(1:10))
#> [1] "ONE" "TWO" "THREE" "FOUR" "FIVE" "SIX" "SEVEN" "EIGHT" "NINE"
#> [10] "TEN"
## For mothers of small children:
cat(paste("This is the", ordinal(1:5), "time I've told you!"), sep = "\n")
#> This is the first time I've told you!
#> This is the second time I've told you!
#> This is the third time I've told you!
#> This is the fourth time I've told you!
#> This is the fifth time I've told you!