Search for objects in the environment
Arguments
- x
character
string used as a grep pattern- where
character
string compatible withbase::ls()
or if installed,AnnotationDbi::ls()
. A special value"all"
will search all environments on the search pathbase::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 forAnnDb
objects, for exampleorg.Mm.egSYMBOL2EG
from theorg.Mm.eg.db
Bioconductor package.- verbose
logical
indicating whether to print verbose output.- ...
additional parameters are ignored.
Value
character
vector of matching object names, or if
where="all"
it returns 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")
.
Examples
# Find all objects named "grep", which should find
# base grep() and jamba::vigrep() among other results.
grepls("grep");
#> $`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: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:jamba`
#> character(0)
#>
#> $`package:base`
#> [1] "charToRaw" "grepRaw"
#>