Daniel Valencia C.
Daniel Valencia C.

Reputation: 2279

How to export successfully a plot from R and changing the point size in pdf format?

I'm doing my manuscript plots using R. The journal require all the text, labels, numbeirng of the plots in 8 pt size. Reading, I found that using pdf() command, I can select the point size and the plot size too. However, the .pdf file is not generated and I got the error:

Error in pdf(file = "test.pdf", width = 5, height = 5, pointsize = 8) : cannot open file 'test.pdf'

I think that I'm doing something wrong. How can I export the file succesfully?

pdf(
  file = "test.pdf",
  width = 5,
  height = 5,
  pointsize = 8
)
plot(1:10)
dev.off()

Upvotes: 0

Views: 262

Answers (1)

Matt
Matt

Reputation: 178

It sounds like an OS issue. Make sure a file test.pdf does not already exist or that you do not have it open. I was able to replicate the error only when I had the existing file opened.

To avoid it in the future, I usually add datetime stamps to the end of my filenames.

Upvotes: 1

Related Questions