Export graph in R - error QuartzBitmap_Output - unable to open file
1
0
Entering edit mode
7.0 years ago
salamandra ▴ 550

In R, whith:

pdf(file="path_to_file/filename")
makeVennDiagram(ol)
dev.off()

or:

png(file="path_to_file/filename")
makeVennDiagram(ol)
dev.off()

I get the error:

Error in dev.off() : 
QuartzBitmap_Output - unable to open file 'path_to_file/filename'

and doesn't save the graph in the folder. Does someone know what is causing this error?

R • 39k views
ADD COMMENT
2
Entering edit mode
7.0 years ago
## Do this in a fresh R session 
# First get the working directory of R. Your plots will be saved here
getwd()

# Then give the pdf output file a name 
pdf(file="myFile.pdf")
makeVennDiagram(ol)
dev.off()

If everything goes fine, you should get the plot in the file "myFile.pdf". Post the error if there is a problem again.

You have used "..." as filename. Any file starting with a "." are normally hidden to the end user; they will not be shown in GUI or by ls command unless you use 'ls -a'

ADD COMMENT
0
Entering edit mode

"..." stands for path_to_file/filename, my mistake. I tried as you said and it created a file in the working directory. But shouldn't be possible to define the directory directly with png(file="path_to_file/filename") ?

ADD REPLY
0
Entering edit mode

that's correct, you could do that! Also you may change your actual directory to the place where you want to do all the calculations by using

setwd("path/to/dir/where/i/want/all/calculations")
ADD REPLY
0
Entering edit mode

it allows to setwd("path/to/dir/where/i/want/all/calculations") but with pdf("path/to/dir/where/i/want/all/calculations") it gives

error: Error in pdf(file = "path/to/dir/where/i/want/all/calculations") : 
  cannot open file 'path/to/dir/where/i/want/all/calculations'

as i can setwd(), the problem isn't with 'path/to/dir/where/i/want/all/calculations'

ADD REPLY
0
Entering edit mode

as i can setwd()

you can setwd() because this is a directory.

pdf("path/to/dir/where/i/want/all/calculations")

You can't create a pdf, because again, this is a directory. You need to give a filename (eg. myFile.pdf)

pdf("path/to/dir/where/i/want/all/calculations/myFile.pdf")
ADD REPLY
0
Entering edit mode

it worked out, thank you

ADD REPLY

Login before adding your answer.

Traffic: 2657 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6