Learn R Programming

safetyGraphics (version 1.1.0)

getSettingKeys: Get setting keys matching a pattern

Description

Recursive function to find all keys matching a given text pattern in a settings list

Usage

getSettingKeys(patterns, settings, parents = NULL, matchLists = FALSE)

Arguments

patterns

List of text patterns to match with named elements in settings.

settings

List of settings used to generate a chart like eDISH().

parents

List containing the position of the parent list using recursive matches.

matchLists

Boolean indicating whether keys containing lists should be returned as matches.

Value

List of lists specifying the position of matching named elements in the format list("filters",2,"value_col"), which would correspond to settings[["filters"]][[2]][["value_col"]].

Details

This function loops through all named elements (or "keys") in a settings list and returns items that match patterns. If matchLists==FALSE (the default), the function iteratively looks through the named elements in nested lists using the built-in parents parameter. The function returns a array of keys for all matches using a list of lists. Each key is defines the position of a matching key using an unnamed list. For example, list("filters",2,"value_col") would correspond to settings[["filters"]][[2]][["value_col"]].

Examples

Run this code
# NOT RUN {
testSettings<-generateSettings(standard="AdAM")

# returns list of all matching values
safetyGraphics:::getSettingKeys(patterns=c("_col"),
                                settings=testSettings)

#finds the matching nested setting 
safetyGraphics:::getSettingKeys(patterns=c("ALP"),
                                settings=testSettings) 

#returns an empty list, since the only matching item is a list
safetyGraphics:::getSettingKeys(patterns=c("measure_values"),
                                settings=testSettings) 

#finds the matching key associated with a list
safetyGraphics:::getSettingKeys(patterns=c("measure_values"),
                                settings=testSettings, 
                                matchLists=TRUE) 

# }

Run the code above in your browser using DataLab