This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Export graph in R - error QuartzBitmap_Output - unable to open file

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

1 answer

## 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'

"..." 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") ?

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")

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'

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")

it worked out, thank you

Log in to answer this question.