[Rd] savePlot() no longer automatically adds an extension to the filename.
Gabor Grothendieck
ggrothendieck at gmail.com
Tue Jun 3 18:02:42 CEST 2008
Not sure if this is sufficient but note that if you leave the filename
off entirely then the extension does default to the type.
savePlot() # wmf
savePlot(type = "jpg")
> args(savePlot)
function (filename = paste("Rplot", type, sep = "."), type = c("wmf",
"emf", "png", "jpg", "jpeg", "bmp", "tif", "tiff", "ps",
"eps", "pdf"), device = dev.cur(), restoreConsole = TRUE)
https://svn.r-project.org/R/trunk/src/library/grDevices/R/windows/windows.R
On Tue, Jun 3, 2008 at 11:22 AM, S Ellison <S.Ellison at lgc.co.uk> wrote:
> Plaintive squeak: Why the change?
>
> Some OS's and desktops use the extension, so forgetting it causes
> trouble. The new default filename keeps a filetype (as before) but the
> user now has to type a filetype twice (once as the type, once as
> extension) to get the same effect fo rtheir own filenames. And the
> extension isn't then checked for consistency with valid file types, so
> it can be mistyped and saved with no warning. Hard to see the advantage
> of doing away with it...
>
> Suggestion: Revert to the previous default (extension as type) and
> include an 'extension' in the parameter list so that folk who don't want
> it can change it and folk who did want it get it automatically.
>
>
> The code would then look something like
>
> savePlot<-function (filename = "Rplot",
> type = c("wmf", "emf", "png", "jpg", "jpeg", "bmp", "tif",
> "tiff", "ps", "eps", "pdf"),
> device = dev.cur(),
> restoreConsole = TRUE,
> extension) #Added extension
> {
> type <- match.arg(type)
> if(missing(extension))
> extension <- type ##added
> devlist <- dev.list()
> devcur <- match(device, devlist, NA)
> if (is.na(devcur))
> stop("no such device")
> devname <- names(devlist)[devcur]
> if (devname != "windows")
> stop("can only copy from 'windows' devices")
> if (filename == "clipboard" && type == "wmf")
> filename <- ""
> else
> fullname <- paste(filename, extension,
> sep=ifelse(extension=="","",".") ) ##added
> invisible(.External(CsavePlot, device, fullname, type,
> restoreConsole)) ##Modded
> }
>
> Steve E
>
> PS Yes, I took a while to upgrade from 2.6.x. Otherwise I'd have
> squeaked the day I upgraded - like I just did - 'cos I use savePlot a
> LOT.
>
>
>
> *******************************************************************
> This email and any attachments are confidential. Any use...{{dropped:8}}
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
More information about the R-devel
mailing list