image - How can I produce more than one file format per plot code in R? -
i use github markdown document data analysis r. when make plot use:
jpeg("file_name.jpg") plot(...) dev.off()
to save plot jpeg can embedded , displayed in markdown document this:
!(file_name.jpg)
however, need make pdf
of plot final publication. write entire plot code on again pdf("file_name.pdf")
results in lot of duplicate code.
i have tried putting jpeg
, pdf
calls in sequence bottom 1 gets produced.
is there way make jpeg
, pdf
file same code during 1 run of code?
or can use dev.copy
:
plot(cars) dev.copy(jpeg, "cars.jpeg") dev.off() dev.copy(pdf, "cars.pdf") dev.off()
Comments
Post a Comment