condGrob: Create a named grob or a template grob depending on a test

condGrobR Documentation

Create a named grob or a template grob depending on a test

Description

Creates and returns a grid object using the function given by 'grobFun' when 'test' is 'TRUE' Otherwise a simple 'grob()' is produced with the same parameters. All grob parameters are given in '...'.

Usage

condGrob(test = TRUE, grobFun = grid::grob, name = "grob name", ...)

Arguments

test

Either 'TRUE' or 'FALSE' to indicate whether 'grobFun' is to be used (default 'TRUE') or not.

grobFun

The function to be used to create the grob when 'test = TRUE' (e.g. 'textGrob', 'polygonGrob', etc.).

name

The name to be used for the returned grob.

...

The arguments to be given to the 'grobFun' (or to 'grob()' when 'test = FALSE').

Value

A grob as produced by either the 'grobFun' given or by 'grob()' using the remaining arguments. If 'test = FALSE' then the name is suffixed by ": 'grobFun name' arguments".

Examples

myGrob <- condGrob(test = (runif(1) > 0.5),
                   grobFun = textGrob,
                   name = "my label",
                   label = "Some random text")
myGrob


loon documentation built on July 9, 2023, 5:48 p.m.