Search for objects in the environment

grepls(
  x,
  where = "all",
  ignore.case = TRUE,
  searchNames = TRUE,
  verbose = FALSE,
  ...
)

Arguments

x

character string used as a grep pattern

where

character string compatible with base::ls() or if installed, AnnotationDbi::ls(). A special value "all" will search all environments on the search path base::search() in order.

ignore.case

logical indicating whether the pattern match is case-insensitive.

searchNames

logical indicating whether names should also be searched, which is only relevant for AnnDb objects, for example org.Mm.egSYMBOL2EG from the org.Mm.eg.db Bioconductor package.

verbose

logical indicating whether to print verbose output.

...

additional parameters are ignored.

Value

vector of matching object names, or if where="all" a named list, whose names indicate the search environment name, and whose entries are matching object names within each environment.

Details

This function searches the active R environment for an object name using vigrep() (value, case-insensitive grep). It is helpful when trying to find an object using a substring, for example grepls("statshits").

See also

Other jam grep functions: igrepHas(), igrepl(), igrep(), provigrep(), unigrep(), unvigrep(), vgrep(), vigrep()

Examples

# Find all objects named "grep", which should find
# base grep() and jamba::vigrep() among other results.
grepls("grep");
#> $`package:grid`
#> [1] "grid.grep"
#> 
#> $`package:S4Vectors`
#> [1] "grep"  "grepl"
#> 
#> $`package:BiocGenerics`
#> [1] "grep"  "grepl"
#> 
#> $`package:jamba`
#>  [1] "grepls"    "igrep"     "igrepHas"  "igrepl"    "proigrep"  "provigrep"
#>  [7] "unigrep"   "unvigrep"  "vgrep"     "vigrep"   
#> 
#> $`package:base`
#> [1] "agrep"   "agrepl"  "grep"    "grepRaw" "grepl"  
#> 

# Find objects in the local environment
allStatsHits <- c(1:12);
someStatsHits <- c(1:3);
grepls("statshits");
#> named list()
# shortcut way to search only the .GlobalEnv, the active local environment
grepls("statshits", 1);
#> character(0)

# return objects with "raw" in the name
grepls("raw");
#> $`package:grid`
#> [1] "draw.details"    "drawDetails"     "grid.draw"       "postDrawDetails"
#> [5] "preDrawDetails" 
#> 
#> $`package:jamba`
#> [1] "drawLabels"
#> 
#> $`package:base`
#>  [1] "all.equal.raw"      "as.data.frame.raw"  "as.raw"            
#>  [4] "charToRaw"          "grepRaw"            "is.raw"            
#>  [7] "raw"                "rawConnection"      "rawConnectionValue"
#> [10] "rawShift"           "rawToBits"          "rawToChar"         
#> 

# Require "Raw" to be case-sensitive
grepls("Raw", ignore.case=FALSE)
#> $`package:grid`
#> character(0)
#> 
#> $`package:jamba`
#> character(0)
#> 
#> $`package:base`
#> [1] "charToRaw" "grepRaw"  
#>