When printing a graph to a file, I want to find the location of the file that I am printing.
pdf("test.pdf")
plot(1:5)
# Somehow retrieve "test.pdf"
dev.off()
In this example, I indicated the file name when I named pdf, so the answer is obvious. My use case is when a file location was automatically generated, for example in a knitr document.
To connect files, you can get the linked file with summary(conn)$description. I was hoping to get something useful from summary(dev.cur())or str(dev.cur()), but you're out of luck.
How can I go from dev.cur()to a linked file? Alternatively, how can I get the location of the file to which the chart is written?
source
share