On Thu, Jul 15, 2010 at 8:43 PM, Erik Iverson <er...@ccbr.umn.edu> wrote: > 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.
Sorry for the lack of details. I'm running R non-interactively (so the default device is the "pdf" one), and I'm running on linux. > 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. That definitely is an option, and if I can't figure out a way to change the default then I might go with a wrapper function like that. My goal is to make sure that I can choose the default name for any output images. In a normal script, you can just start plotting things (like in my example) without creating a device or setting the graphics driver first. It just uses the default. I can change the default device, but my goal is also to change the default filename as well. So instead of: > mypng() > x=c(1,2,3) > plot(x,x) I can just do: > x=c(1,2,3) > plot(x,x) Thanks for the help so far! -James [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.