Description Usage Arguments Value See Also Examples
as_enum()
turns an existing object into an enumeration. Coercion
can be used when you want to create an enum, but don't know
what the exact values each member will contain at runtime. This is comparable
to the as.list
method.
As an S3 generic, as_enum()
holds methods for:
list
: wrapper function that passes the list to
new_generic_enum()
data.frame
: coerces a data.frame to a list (
dropping row names in the process), and supplies the list of objects
to new_generic_enum()
environment
: coerces an environment to a list,
and supplies the list of objects to new_generic_enum()
factor
: constructs a list of name/value pairs
from a factor, supplies the list to new_numeric_enum()
.
Default: attempt to coerce to a list, then to an enum
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | as_enum(x, ...)
## S3 method for class 'list'
as_enum(x, ...)
## S3 method for class 'environment'
as_enum(x, ..., .all_names = FALSE, .sorted = TRUE)
## S3 method for class 'factor'
as_enum(x, ..., .sorted = TRUE)
## S3 method for class 'data.frame'
as_enum(x, ..., use_cols = FALSE, use_rows = FALSE)
## S3 method for class ''NULL''
as_enum(x, ...)
## Default S3 method:
as_enum(x, ...)
|
x |
the object to coerce to enum |
... |
parameters to pass to further methods |
.all_names |
whether to include variables with a dot |
.sorted |
whether the object elements should be sorted |
use_cols |
cols of the data frame are used for name/value pairs instead of the data frame's observations |
use_rows |
rows of the data frame are used for name/value pairs instead of the data frame's observations |
An enumeration (enum), a list of unique name/value pairs
enum()
create an enum from supplied arguments.
new_generic_enum()
and new_numeric_enum()
create enums from
a list of arguments.
1 2 3 4 5 6 7 8 9 10 11 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.