Skip to content
Prev 29092 / 63424 Next

savePlot() no longer automatically adds an extension to the filename.

On Jun 3, 2008, at 8:40 PM, Duncan Murdoch wrote:

            
AFAICS the savePlot() behavior is now (as of r45830) inconsistent  
across platforms due to the patch (r458229). The inconsistency is IMHO  
a bad thing - you shouldn't expect the same function to behave  
differently across platforms.

I'd strongly recommend against this change for several reasons: it  
changes the behavior of the function between 2.7.0 and 2.7.1, so that  
now you have to special-case three different versions (pre 2.7.0,  
2.7.0 and 2.7.1), there is now no way to specify a file without a dot  
(which is quite common in non-Windows world) and the behavior is  
incompatible with other similar functions.

I think the change of behavior in 2.7.0 was deliberate and in favor of  
consistency, because a filename specification should not be randomly  
mangled by the function (I have made that mistake myself before, so I  
know the pitfalls ;)). Extension is part of the filename, it's not a  
separate concept (also note that ".foo" is a valid  filename that  
doesn't have an extension). The argument about typos is moot since you  
can always define functions like
saveFoo <- function(prefix) savePlot(filename = paste(prefix, "foo",  
sep="."), type="foo")
At any rate I don't see how this can realistically be part of 2.7.1  
since it's not a bugfix and it changes the meaning of a function  
parameter. (And I usually don't mind disguising small features as  
bugfixes ;P)

Whether the change in 2.7.0 could be done differently (e.g. using  
another parameter for a full file name) is a different story, but I  
suspect that it should have been discussed before the 2.7.0 release...

Cheers,
Simon