James
2010-Jul-16 00:10 UTC
[R] Can I set default parameters for the default graphics device?
I'm completely new to R, and I'd like to do something like this:
> x=c(1,2,3)
> plot(x,x)
At this point, R creates a file "Rplots.pdf", since the default device
is
PDF and the default filename is "Rplots.pdf". I know I can set the
default
device like this:
> options(device="png")
But is there a way to set the default device's default filename?
Thanks!
[[alternative HTML version deleted]]
Sam Albers
2010-Jul-16 00:36 UTC
[R] Can I set default parameters for the default graphics device?
Unless you aren't writing scripts why wouldn't you just use something like this?> x=c(1,2,3) > pdf("RRules.pdf") > plot(x,x) > dev.off()-- View this message in context: http://r.789695.n4.nabble.com/Can-I-set-default-parameters-for-the-default-graphics-device-tp2290827p2290836.html Sent from the R help mailing list archive at Nabble.com.
Erik Iverson
2010-Jul-16 00:43 UTC
[R] Can I set default parameters for the default graphics device?
On 07/15/2010 07:10 PM, James wrote:> I'm completely new to R, and I'd like to do something like this: > > > x=c(1,2,3) > > plot(x,x) > > At this point, R creates a file "Rplots.pdf", since the default device is > PDF and the default filename is "Rplots.pdf".Since you're completely new to R, I might ask what OS you're using, and if you're using R interactively? If you are using R interactively, the default device would probably create a new 'window' to display the graphic in. If you're running in batch mode, then pdf is the default. I know I can set the default> device like this: > > > options(device="png") > > But is there a way to set the default device's default filename?I guess you can probably just write your own wrapper function and use that as the device name. Try: mypng <- function(filename = "mydefault.png", ...) { png(filename, ...) } options(device = "mypng") I did not test any of this, but I hope it works.