umx (version 1.9.1)

umx_names: umx_names

Description

Convenient equivalent of grep("fa[rl].*", names(df), value = TRUE, ignore.case = TRUE) Can handle dataframe (uses names), model (uses parameter names), or a vector of strings.

Usage

umx_names(df, pattern = ".*", replacement = NULL, ignore.case = TRUE,
  perl = FALSE, value = TRUE, fixed = FALSE, useBytes = FALSE,
  invert = FALSE)

Arguments

df

dataframe from which to get names.

pattern

used to filter-out only some names (supports wild card/regular expressions)

replacement

if not NULL, replaces the found string.

ignore.case

default = TRUE (opposite default to grep)

perl

= FALSE

value

= default = TRUE (opposite default to grep)

fixed

= FALSE

useBytes

= FALSE

invert

= FALSE

Value

- vector of matches

References

- http://tbates.github.io, https://github.com/tbates/umx

See Also

- grep, sub

Other Utility Functions: qm, umx_find_object, umx_msg, umx_paste_names, umx_pb_note, umx_print, umx_rename, umx

Examples

Run this code
# NOT RUN {
umx_names(mtcars, "mpg") # just "mpg" matches
umx_names(mtcars, "^d") # "disp", drat
umx_names(mtcars, "r[ab]") # "drat", "carb"
umx_names(mtcars, "mpg", replacement = "hello") # "mpg" replaced with "hello"
# }
# NOT RUN {
# TODO umx_names: Add GFF examples to umx_names

umx_names(nl, "1$")
# "zyg" "sex1"  "age1"  "gff1"  "fc1"   "qol1"  "hap1"  "sat1"  "AD1" "SOMA1" "SOC1"  "THOU1"
umx_names(nl, "2$")

umx_names(nl, "b$")
umx_names(nl, "s$")
umx_names(nl, "[^12bs]$")
# "divorce"
# }

Run the code above in your browser using DataLab