Last data update: 2014.03.03

R: Evaluate an R expression with graphical parameters set...
withParR Documentation

Evaluate an R expression with graphical parameters set temporarily

Description

Evaluate an R expression with graphical parameters set temporarily.

Usage

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

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))

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(R.devices)
R.devices v2.14.0 (2016-03-08) successfully loaded. See ?R.devices for help.
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/R.devices/withPar.Rd_%03d_medium.png", width=480, height=480)
> ### Name: withPar
> ### Title: Evaluate an R expression with graphical parameters set
> ###   temporarily
> ### Aliases: withPar
> ### Keywords: IO programming
> 
> ### ** Examples
> 
> 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))
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>