Skip to contents

Find list objects whose names contain any elements of x. Note that data.frame objects are considered list objects.

Usage

in_which(x, envir = .GlobalEnv, ignore_case = TRUE)

Arguments

x

a character vector where matches to any elements are sought.

envir

which environment to use in listing the available objects. Defaults to the global environment. This can also be a list containing objects to check.

ignore_case

logical representing whether to ignore case.

Value

returns a named list of character vectors containing the names of list objects with some names matching to x or invisibly returns NULL where there are no list objects in envir.

Examples

data(mtcars); in_which("cyl")
#> $cyl
#> [1] "mtcars"
#> 

# check for common subject identifiers, explicitly defining case
in_which(
  c("ID", "SUBJECT", "SUBJID", "USUBJID"), 
  ignore_case = FALSE
)
#> $ID
#> [1] "dmcognigen_cov"
#> 
#> $SUBJECT
#> character(0)
#> 
#> $SUBJID
#> [1] "dmcognigen_cov"
#> 
#> $USUBJID
#> [1] "dmcognigen_cov"
#>