xmu_match.arg: Select first item in list of options, while being flexible...

xmu_match.argR Documentation

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 match.arg() xmu_match.arg allows items not in the list.

Usage

xmu_match.arg(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

See Also

  • match.arg()

Other xmu internal not for end user: umxModel(), umxRenameMatrix(), umx_APA_pval(), umx_fun_mean_sd(), umx_get_bracket_addresses(), umx_make(), umx_standardize(), umx_string_to_algebra(), xmuHasSquareBrackets(), xmuLabel_MATRIX_Model(), xmuLabel_Matrix(), xmuLabel_RAM_Model(), xmuMI(), xmuMakeDeviationThresholdsMatrices(), xmuMakeOneHeadedPathsFromPathList(), xmuMakeTwoHeadedPathsFromPathList(), xmuMaxLevels(), xmuMinLevels(), xmuPropagateLabels(), xmuRAM2Ordinal(), xmuTwinSuper_Continuous(), xmuTwinSuper_NoBinary(), xmuTwinUpgradeMeansToCovariateModel(), xmu_CI_merge(), xmu_CI_stash(), xmu_DF_to_mxData_TypeCov(), xmu_PadAndPruneForDefVars(), xmu_bracket_address2rclabel(), xmu_cell_is_on(), xmu_check_levels_identical(), xmu_check_needs_means(), xmu_check_variance(), xmu_clean_label(), xmu_data_missing(), xmu_data_swap_a_block(), xmu_describe_data_WLS(), xmu_dot_make_paths(), xmu_dot_make_residuals(), xmu_dot_maker(), xmu_dot_move_ranks(), xmu_dot_rank_str(), xmu_extract_column(), xmu_get_CI(), xmu_lavaan_process_group(), xmu_make_TwinSuperModel(), xmu_make_bin_cont_pair_data(), xmu_make_mxData(), xmu_name_from_lavaan_str(), xmu_path2twin(), xmu_path_regex(), xmu_print_algebras(), xmu_rclabel_2_bracket_address(), xmu_relevel_factors(), xmu_safe_run_summary(), xmu_set_sep_from_suffix(), xmu_show_fit_or_comparison(), xmu_simplex_corner(), xmu_standardize_ACE(), xmu_standardize_ACEcov(), xmu_standardize_ACEv(), xmu_standardize_CP(), xmu_standardize_IP(), xmu_standardize_RAM(), xmu_standardize_SexLim(), xmu_standardize_Simplex(), xmu_start_value_list(), xmu_starts(), xmu_summary_RAM_group_parameters(), xmu_twin_add_WeightMatrices(), xmu_twin_check(), xmu_twin_get_var_names(), xmu_twin_make_def_means_mats_and_alg(), xmu_twin_upgrade_selDvs2SelVars()

Examples

option_list = c("default", "par.observed", "empirical")

xmu_match.arg("par.observed", option_list)
xmu_match.arg("allow me", option_list, check = FALSE)
xmu_match.arg(option_list, option_list)
option_list = c(NULL, "par.observed", "empirical")
 # fails with NULL!!!!!
xmu_match.arg(option_list, option_list)
option_list = c(NA, "par.observed", "empirical")
xmu_match.arg(option_list, option_list) # use NA instead
option_list = c(TRUE, FALSE, NA)
xmu_match.arg(option_list, option_list) # works with non character
# An example of checking a bad item and stopping
## Not run: 
	tmp <- function(x= c("one", "two", "three")) {
		xmu_match.arg(x, option_list = c("one", "two", "three"))
	}
testthat::expect_true(tmp() == "one")
testthat::expect_error(tmp("bad"))
	tmp <- function(x= c("one", "two", "three")) {
		xmu_match.arg(x, option_list = c("one", "two", "three"), check = FALSE)
	}
testthat::expect_true(tmp("OK") == "OK")
testthat::expect_error(tmp(), NA)

## End(Not run)

tbates/umx documentation built on Dec. 14, 2024, 11:28 a.m.