Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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://github.com/tbates/umx>

See Also

Examples

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)

## End(Not run)

umx

Structural Equation Modeling and Twin Modeling in R

v4.10.10
GPL-3
Authors
Timothy C. Bates [aut, cre] (<https://orcid.org/0000-0002-1153-9007>), Gillespie Nathan [wit], Michael Zakharin [wit], Brenton Wiernik [ctb], Joshua N. Pritikin [ctb], Michael C. Neale [ctb], Hermine Maes [ctb]
Initial release
2021-11-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.