[R-SIG-Mac] saving files using quartz engine

Denis Chabot chabotd at globetrotter.net
Sun Nov 20 02:02:42 CET 2011


Dear Ross,

I apologize, there was careless cut and paste, I am sorry. And my message took long to appear on the list because I accidentally used an email address other than the one I subscribed with, so that it had to be cleared manually before it appeared. Thanks to the moderator for allowing it, by the way, and to you for pointing the error.

I was a bit behind at the time (R 2.13.1, but 2.13.2 was out). I am way behind now, as I did not have time to upgrade to 2.14. I cannot be certain this is still an issue, but I would like to at least post a correct example.

pdf(file="/Users/dchabot/Documents/Programmes R/test.pdf") # works
plot(1:10)
dev.off()

pdf(file="~/Documents/Programmes R/test.pdf") # works
plot(1:10)
dev.off()

quartz(file="~/Documents/Programmes R/test.pdf", type="pdf") # does not work
plot(1:10)
dev.off()

quartz(file="/Users/dchabot/Documents/Programmes R/test.pdf", type="pdf") # works
plot(1:10)
dev.off()

Only the 3rd example does not work:

> quartz(file="~/Documents/Programmes R/test.pdf", type="pdf") # does not work
Erreur dans quartz(file = "~/Documents/Programmes R/test.pdf", type = "pdf") : 
 Impossible de créer le périphérique cible Quartz, le type fourni n'est peut-être pas supporté.
> plot(1:10)
> dev.off()
null device 
         1 
Sat Nov 19 19:47:13 MBPi7Chabot.local R[389] <Error>: CGDataConsumerCreateWithFilename: failed to open `/Users/dchabot/~/Documents/Programmes R/test.pdf' for writing: No such file or directory.
deflateEnd: error -3: (null).
Sat Nov 19 19:47:13 MBPi7Chabot.local R[389] <Error>: CGPDFContextCreate: failed to create PDF context delegate.

In his reply to my post, Prof. Ripley said that tilde expansion had to be implemented into each graphics device. I did not know that, I thought it was built-in R because of its Unix roots. So I guess we now have the answer. It is not a big deal having to write the complete path, it just took me by surprise. 

I would like to offer to add tilde expansion to quartz(), but I am not qualified to do so.

Denis
Le 2011-11-19 à 16:35, <Ross.Darnell at csiro.au> <Ross.Darnell at csiro.au> a écrit :

> Are you sure the second case works?
> 
> Ross Darnell 
> 
> 
> 
> On 3/11/11 12:21 PM, "Denis Chabot" <chabot.denis at gmail.com> wrote:
> 
>> Hi,
>> 
>> is there a reason that the quartz device does not like the "~" in file
>> names, whereas most functions handling files (including pdf() ) have no
>> problem with it?
>> 
>> Thus 
>> 
>> pdf(file="/Users/dchabot/Documents/Programmes R/test.pdf", type="pdf",
>> width=6, height=5) # works
>> pdf(file=~/Documents/Programmes R/test.pdf", type="pdf", width=6,
>> height=5) # works
>> 
>> quartz(file="~/Documents/Programmes R/test.pdf", type="pdf", width=6,
>> height=5) # does not work
>> quartz(file="/Users/dchabot/Documents/Programmes R/test.pdf", type="pdf",
>> width=6, height=5) # works
>> 
>> Cheers,
>> 
>> Denis
>> 
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 



More information about the R-SIG-Mac mailing list