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

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
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, ...)

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.

...

Currently unused.

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 at http://tolstoy.newcastle.edu.au/R/help/05/04/2715.html.

See Also

as.character.english, print.english.

Examples

1
2
3
4
english(1010, UK = FALSE)
english(1010, UK = TRUE)
english(101)       ## UK not given: result will depend on the locale
as.english(10001001) + (-5):5

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

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