umx_grep: Search for text

Description Usage Arguments Details Value References See Also Examples

View source: R/misc_and_utility.R

Description

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

Usage

1
2
3
4
5
6
7
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

References

See Also

Other String Functions: umx_explode_twin_names(), umx_explode(), umx_names(), umx_object_as_str(), umx_paste_names(), umx_rot(), umx_trim(), umx

Examples

1
2
3
4
5
6
7
8
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)

tbates/umx documentation built on March 30, 2020, 7:56 a.m.