Description Usage Arguments Details Value Examples
A reference class must specify its fields, for example,
c(data = "data.frame", ntrees = "integer")
. These fields
can be provided in several formats. The goal of this function is to
ensure that format is correct, make small modifications if necessary,
and error if there are problems.
1 | format_types_list(props, what = "field")
|
props |
character or list. See full description of this function. |
what |
character. The name of the thing we are creating a
types list for. The default is |
The following are valid formats for props
:
"character""A named character vector with non-empty and distinct names.
"list""A named list with non-empty and distinct names, and character values of length 1."
"unnamed character""A totally unnamed character vector with
non-empty and distinct values. These will be turned into the names
of a character vector with values 'ANY'
.
If the provided props
does not satisfy any of these, an error
will be invoked.
# TODO: (RK) Figure out what inferring means...
a list that is guaranteed to have distinct non-zero length names and values that are of type character of length 1.
1 2 3 4 5 6 | stopifnot(identical(format_types_list(c(a = 'character', b = 'data.frame')),
list(a = 'character', b = 'data.frame')))
stopifnot(identical(format_types_list(c('a', 'b')), list(a = 'ANY', b = 'ANY')))
stopifnot(identical(format_types_list(list(a = 'character')), list(a = 'character')))
# The following will error because of duplicate names:
# format_types_list(list(a = 'character', a = 'character'))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.