evalOrEcho
to process arguments inside a function can make for
more flexible code.evalOrEcho(x, resultMode = NULL, n = 0)
x
is
considered to have failed if the resulting object is not of this
mode.parent.frame(n)
(of the caller).x
is successfully parsed and evaluated, and its mode matches
resultMode
(if supplied), the resulting object is returned.
Otherwise, x
itself is returned.tisPlot
has a
number or arguments that specify text labels for headers, subheaders,
footnotes, axis labels, and so on. One of those arguments is
sub
, which specifies the subheader. By doing this: sub <- evalOrEcho(sub, resultMode = "character")
tisPlot
can handle the sub
argument given in any of
these forms:
sub = "This is a simple subtitle"
.sub = c("this is a two", "line subtitle")
.sub = 'c("this is another", "two line subtitle")'
.try