Tim
Tim

Reputation: 1479

How to hide figures in knitr, but create them as png?

I am currently doing some statistical analysis in R and use knitr to generate results and an overview document.

There are some additional plots, which I want to be done and saved as a .png (with specified file name and location), but not included in the generated .html file (too many of them, and they are not at the end).

Using dev.copy(png, ...) works fine for generating the plots, but the figures appear in the .html. If I specify fig.keep=none the .png files are created, but blank.

Is there some way to do what I want?

Upvotes: 11

Views: 4094

Answers (1)

Roman Luštrik
Roman Luštrik

Reputation: 70653

This is from knitr website:

fig.show: ('asis'; character) how to show/arrange the plots; four possible values are

  • asis: show plots exactly in places where they were generated (as if the code were run in an R terminal)

  • hold: hold all plots and output them in the very end of a code chunk

  • animate: wrap all plots into an animation if there are mutiple plots in a chunk

  • hide: generate plot files but hide them in the output document

fig.show = 'hide' worked for me.

Upvotes: 19

Related Questions