Learn R Programming

umx (version 1.9.1)

umx_default_option: Select first item in list of options, while being flexible about choices.

Description

Like a smart version of match.arg: Handles selecting parameter options when default is a list. Unlike x = match.arg(x) this allows items not in the list.

Usage

umx_default_option(x, option_list, check = TRUE)

Arguments

x

the value chosen (may be the default option list)

option_list

A vector of valid options

check

Whether to check that single items are in the list. Set false to accept abbreviations (defaults to TRUE)

Value

- one validated option

References

- http://www.github.com/tbates/umx

See Also

- match.arg

Other Misc: umxEval, umx_APA_model_CI, umx_add_variances, umx_apply, umx_get_bracket_addresses, umx_object_as_str, umx_string_to_algebra, umx

Examples

Run this code
# NOT RUN {
option_list = c("default", "par.observed", "empirical")
umx_default_option("par.observed", option_list)

# An example of checking a bad item and stopping
# }
# NOT RUN {
umx_default_option("bad", option_list)
# }
# NOT RUN {
umx_default_option("allow me", option_list, check = FALSE)
umx_default_option(option_list, option_list)
option_list = c(NULL, "par.observed", "empirical")
 # fails with NULL!!!!!
umx_default_option(option_list, option_list)
option_list = c(NA, "par.observed", "empirical")
umx_default_option(option_list, option_list) # use NA instead
option_list = c(TRUE, FALSE, NA)
umx_default_option(option_list, option_list) # works with non character
# }

Run the code above in your browser using DataLab