withPar: Evaluate an R expression with graphical parameters set...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/withPar.R

Description

Evaluate an R expression with graphical parameters set temporarily.

Usage

1
withPar(expr, ..., args=list(), envir=parent.frame())

Arguments

expr

The R expression to be evaluated.

...

Named options to be used.

args

(optional) Additional named options specified as a named list.

envir

The environment in which the expression should be evaluated.

Details

Upon exit (also on errors), this function will reset all (modifiable) graphical parameters to the state of options available upon entry. This means any parameters modified from evaluating expr will also be undone upon exit.

Value

Returns the results of the expression evaluated.

Author(s)

Henrik Bengtsson

See Also

Internally, eval() is used to evaluate the expression, and par to set graphical parameters.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
withPar({
  layout(1:4)

  withPar({
    plot(1:10)
    plot(10:1)
  }, pch=4)

  withPar({
    plot(1:10)
    plot(10:1)
  }, pch=0, bg="yellow")
}, mar=c(2,2,1,1))

R.devices documentation built on Oct. 30, 2019, 10:58 a.m.