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

umx_grep

Search for text


Description

Search names if given a data.frame, or strings if given a vector of strings.

Usage

umx_grep(
  df,
  grepString,
  output = c("both", "label", "name"),
  ignore.case = TRUE,
  useNames = FALSE
)

Arguments

df

The data.frame() or string to search.

grepString

the search string.

output

the column name, the label, or both (default).

ignore.case

whether to be case sensitive or not (default TRUE = ignore case).

useNames

whether to search the names as well as the labels (for SPSS files with label metadata).

Details

The namez function is more flexible. A handy feature of umx_grep is that it can search the labels of data imported from SPSS.

nb: To simply grep for a pattern in a string use R's built-in grep() functions, e.g.: grepl("^NA\\[0-9]", "NA.3")

Value

  • list of matched column names and/or labels.

References

See Also

Examples

umx_grep(mtcars, "hp", output="both", ignore.case= TRUE)
umx_grep(c("hp", "ph"), "hp")
umx_grep(mtcars, "^h.*", output="both", ignore.case= TRUE)
## Not run: 
umx_grep(spss_df, "labeltext", output = "label") 
umx_grep(spss_df, "labeltext", output = "name") 

## 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.