umx (version 4.0.0)

umx_check_names: Check if a request name exists in a dataframe or related object

Description

Check if a list of names are in the [namez()] of a dataframe (or the [dimnames()] of a matrix), or the names of the observed data of an [mzData()]

Usage

umx_check_names(
  namesNeeded,
  data = NA,
  die = TRUE,
  no_others = FALSE,
  intersection = FALSE,
  message = ""
)

Arguments

namesNeeded

list of variable names to find (a dataframe is also allowed)

data

data.frame, matrix, or mxData to search in for names (default NA)

die

whether to die if the check fails (default TRUE)

no_others

Whether to test that the data contain no columns in addition to those in namesNeeded (default FALSE)

intersection

Show the intersection of names

message

Some helpful text to append when dieing.

References

- <https://www.github.com/tbates/umx>

See Also

Other Test: umx_check_OS(), umx_check_model(), umx_check_parallel(), umx_check(), umx_has_CIs(), umx_has_been_run(), umx_has_means(), umx_has_square_brackets(), umx_is_MxData(), umx_is_MxMatrix(), umx_is_MxModel(), umx_is_RAM(), umx_is_cov()

Other Check or test: umx_is_class(), umx_is_endogenous(), umx_is_exogenous(), umx_is_numeric(), umx_is_ordered(), umx

Examples

Run this code
# NOT RUN {
require(umx)
data(demoOneFactor) # "x1" "x2" "x3" "x4" "x5"
umx_check_names(c("x1", "x2"), demoOneFactor)
umx_check_names(c("x1", "x2"), as.matrix(demoOneFactor))
umx_check_names(c("x1", "x2"), cov(demoOneFactor[, c("x1","x2")]))
umx_check_names(c("x1", "x2"), mxData(demoOneFactor, type="raw"))
umx_check_names(c("z1", "x2"), data = demoOneFactor, die = FALSE)
umx_check_names(c("x1", "x2"), data = demoOneFactor, die = FALSE, no_others = TRUE)
umx_check_names(c("x1","x2","x3","x4","x5"), data = demoOneFactor, die = FALSE, no_others = TRUE)
# no request
umx_check_names(c(), data = demoOneFactor, die = FALSE, no_others = TRUE)

# }
# NOT RUN {
# An example error from vars that don't exist in the data
umx_check_names(c("bad_var_name", "x2"), data = demoOneFactor, die = TRUE)
# }

Run the code above in your browser using DataLab