umx (version 1.9.1)

umx_grep: umx_grep

Description

Search for text. Will search names if given a data.frame, or strings if given a vector of strings. NOTE: Handy feature is that this can search the labels of data imported from SPSS

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)

Value

- list of matched column names and/or labels

Details

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

References

- http://www.github.com/tbates/umx

See Also

- grep umx_names umx_aggregate

Other Miscellaneous Utility Functions: umxVersion, umx_make, umx_write_to_clipboard

Other String Functions: umx_explode_twin_names, umx_explode, umx_rot, umx_trim

Examples

Run this code
# NOT RUN {
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") 
# }

Run the code above in your browser using DataCamp Workspace