as.english: Generic functions and methods for S3 class english

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

The functions as.english and english are fully equivalent generic constructor functions for the S3 class english, which allows numeric objects to be represented in the form of their customary English expression.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
as.english(x, ...)
english(x, ...)
## Default S3 method:
english(x, ...)
## S3 method for class 'numeric'
english(x, UK, ...)
## S3 method for class 'english'
english(x, UK, ...)
## S3 method for class 'english'
x[i]
## S3 method for class 'english'
rep(x, ...)
## S3 method for class 'english'
format(x, ...)

Arguments

x

Any numeric object. If the components are not integers, they are rounded. In the case of english.default this may be an object of any class, but will always result in an error.

UK

A logical flag, should English-style numbers be given (TRUE) or American style (FALSE)? If missing, a default value is chosen as TRUE unless the locale in use is guessed to be an English locale of the USA.

...

For rep, and format arguments passed on to other methods. Ignored in all other cases.

i

Any allowable form of index vector.

Details

The function english is a generic constructor function for objects of class english. The methods either mark the object as having the appropriate class, or, in the case of english.default, result in an error message. The function as.english is provided as a corresponding function to as.roman in the utils package. The method english.english simply allows the constructor function to act as a coercion and to have no effect on objects already of the class.

Value

An object of class english, if possible, or an error message if not.

Author(s)

John Fox and Bill Venables

References

See original note by John Fox in the Programmers Niche section of https://cran.r-project.org/doc/Rnews/Rnews_2005-1.pdf.

See Also

as.character.english, print.english.

Examples

1
2
3
4
5
6
7
8
english(1010, UK = FALSE)
english(1010, UK = TRUE)
## The default UK setting will depend on the locale:
cat("\n", ifelse(grepl("^(en_us|english_united)",
    tolower(Sys.getlocale("LC_CTYPE"))), "USA", "UK"),
    "English is your default\n")
english(101)       ## UK not given: deduced from locale
as.english(10001001) + (-5):5


Search within the english package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.