a grob or NULL. If NULL, the display list
is searched.
grobs
A logical value indicating whether to search for grobs.
viewports
A logical value indicating whether to search for
viewports.
strict
A boolean indicating whether the path must be matched
exactly.
grep
Whether the path should be treated as a regular expression.
global
A boolean indicating whether the function should affect just the
first match of the path, or whether all matches should be
affected.
no.match
The value to return if no matches are found.
Value
Either a gPath or, if global is TRUE a list of gPaths.
If there are no matches, no.match is returned.
See Also
grid.ls()
Examples
# A gTree, called "grandparent", with child gTree,
# called "parent", with childrenvp vpStack (vp2 within vp1)
# and child grob, called "child", with vp vpPath (down to vp2)
sampleGTree <- gTree(name="grandparent",
children=gList(gTree(name="parent",
children=gList(grob(name="child", vp="vp1::vp2")),
childrenvp=vpStack(viewport(name="vp1"),
viewport(name="vp2")))))
# Searching for grobs
grid.grep("parent", sampleGTree)
grid.grep("parent", sampleGTree, strict=TRUE)
grid.grep("grandparent", sampleGTree, strict=TRUE)
grid.grep("grandparent::parent", sampleGTree)
grid.grep("parent::child", sampleGTree)
grid.grep("[a-z]", sampleGTree, grep=TRUE)
grid.grep("[a-z]", sampleGTree, grep=TRUE, global=TRUE)
# Searching for viewports
grid.grep("vp1", sampleGTree, viewports=TRUE)
grid.grep("vp2", sampleGTree, viewports=TRUE)
grid.grep("vp", sampleGTree, viewports=TRUE, grep=TRUE)
grid.grep("vp2", sampleGTree, viewports=TRUE, strict=TRUE)
grid.grep("vp1::vp2", sampleGTree, viewports=TRUE)
# Searching for both
grid.grep("[a-z]", sampleGTree, viewports=TRUE, grep=TRUE, global=TRUE)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(grid)
> png(filename="/home/ddbj/snapshot/RGM3/R_rel/result/grid/grid.grep.Rd_%03d_medium.png", width=480, height=480)
> ### Name: grid.grep
> ### Title: Search for grobs
> ### Aliases: grid.grep
> ### Keywords: dplot
>
> ### ** Examples
>
> # A gTree, called "grandparent", with child gTree,
> # called "parent", with childrenvp vpStack (vp2 within vp1)
> # and child grob, called "child", with vp vpPath (down to vp2)
> sampleGTree <- gTree(name="grandparent",
+ children=gList(gTree(name="parent",
+ children=gList(grob(name="child", vp="vp1::vp2")),
+ childrenvp=vpStack(viewport(name="vp1"),
+ viewport(name="vp2")))))
> # Searching for grobs
> grid.grep("parent", sampleGTree)
grandparent::parent
> grid.grep("parent", sampleGTree, strict=TRUE)
character(0)
> grid.grep("grandparent", sampleGTree, strict=TRUE)
grandparent
> grid.grep("grandparent::parent", sampleGTree)
grandparent::parent
> grid.grep("parent::child", sampleGTree)
grandparent::parent::child
> grid.grep("[a-z]", sampleGTree, grep=TRUE)
grandparent
> grid.grep("[a-z]", sampleGTree, grep=TRUE, global=TRUE)
[[1]]
grandparent
[[2]]
grandparent::parent
[[3]]
grandparent::parent::child
> # Searching for viewports
> grid.grep("vp1", sampleGTree, viewports=TRUE)
vp1
> grid.grep("vp2", sampleGTree, viewports=TRUE)
vp1::vp2
> grid.grep("vp", sampleGTree, viewports=TRUE, grep=TRUE)
vp1
> grid.grep("vp2", sampleGTree, viewports=TRUE, strict=TRUE)
character(0)
> grid.grep("vp1::vp2", sampleGTree, viewports=TRUE)
vp1::vp2
> # Searching for both
> grid.grep("[a-z]", sampleGTree, viewports=TRUE, grep=TRUE, global=TRUE)
[[1]]
grandparent
[[2]]
grandparent::parent
[[3]]
vp1
[[4]]
vp1::vp2
[[5]]
grandparent::parent::child
>
>
>
>
>
> dev.off()
null device
1
>