Skip to content

how to specify dev.print target by a variable?

3 messages · Leif Kirschenbaum, Berwin A Turlach, Brian Ripley

#
I want to do the following:

  DEVw=500
  DEVh=350
  fname="my_plot"
  dev.print(file=fname, device=FOO, width=DEVw, height=DEVh, bg="transparent")

How do I do this such that I can specify FOO to be one of several choices? (GDD, PNG, postscript, etc.)
If I make FOO a character variable, then "dev.print" complains.
I tried a simpled "substitute" but didn't get it to work...
I'm thinking it's going to involve a "do.call" and "substitute" but I'm not sure.

Using:

$platform[1] "i386-pc-mingw32"
$arch[1] "i386"
$os[1] "mingw32"
$system[1] "i386, mingw32"
$status[1] ""
$major[1] "2"
$minor[1] "2.0"
$year[1] "2005"
$month[1] "10"
$day[1] "06"
$"svn rev"[1] "35749"
$language[1] "R"

and also running the same code on:

$platform[1] "i686-redhat-linux-gnu"
$arch[1] "i686"
$os[1] "linux-gnu"
$system[1] "i686, linux-gnu"
$status[1] ""
$major[1] "2"
$minor[1] "0.0"
$year[1] "2004"
$month[1] "10"
$day[1] "04"
$language[1] "R"


-Leif S. Kirschenbaum, Ph.D.
 Yield Integration Engineer
 Reflectivity, Inc.
#
G'day Leif,
LK> How do I do this such that I can specify FOO to be one of
    LK> several choices? (GDD, PNG, postscript, etc.)  If I make FOO a
    LK> character variable, then "dev.print" complains.
Mmh, I am not sure what the complaint of R 2.2.0 on MS Windows is, but
I guess it is the same as under linux:
Error in dev.copy(device = "png", file = fname, width = DEVw, height = DEVh,  : 
	'device' should be a function

Which is very informative.  `device' is supposed to be a function, not
a character variable, thus:
X11 
  2
X11 
  2 

all seem to work.

HTH.

Cheers,

        Berwin

========================== Full address ============================
Berwin A Turlach                      Tel.: +61 (8) 6488 3338 (secr)   
School of Mathematics and Statistics        +61 (8) 6488 3383 (self)      
The University of Western Australia   FAX : +61 (8) 6488 1028
35 Stirling Highway                   
Crawley WA 6009                e-mail: berwin at maths.uwa.edu.au
Australia                        http://www.maths.uwa.edu.au/~berwin
#
On Fri, 23 Dec 2005, Berwin A Turlach wrote:

            
And my guess is that Leif wants to be able to do

mydevice <- "png"
dev.print(device = get(mydevice), ...)
                    ^^^