enum | R Documentation |
Create enumeration pseudo type as S3 'enum' class from a list of named arguments
enum(...)
... |
One or more named arguments all of the same type. Alternatively it can be one single list or atomic vector. |
'enum()' will try to coerce values to integer and throw an error if that fails. The consequence of this that it will also fail when a list/vector is not the first argument. If a list/vector is indeed the first argument all remaining arguments will be ignored.
A named atomic vector of class 'enum'
myEnum <- enum(a=1, b=3, c=5) inEnum(3, myEnum) # TRUE inEnum("b", myEnum) # TRUE inEnum(2, myEnum) # FALSE, however ... inEnum(myEnum[3], myEnum) # TRUE inEnum(myEnum["c"], myEnum) # TRUE enum(LETTERS[1:3])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.