M. Elliott
M. Elliott

Reputation: 129

How to suppress dev.off() messages in knitr chunk options with markdown in R

I have a chunk of code I don't want to split up in my .rmd file that I'm knitting in RStudio.

My global options are:

{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, autodep = T, message = FALSE, warnings = FALSE, cache=TRUE, messages=FALSE)

Even my chunk option is:

{r section025, message=FALSE, warning=FALSE}
code here

And the PDF output shows the following in the middle of the page where I have saved an image out in my code:

## pdf 
## 2

I seem to have used all the suppression options, so I cannot figure out why this still appears. Thoughts appreciated.

Upvotes: 6

Views: 2786

Answers (2)

splaisan
splaisan

Reputation: 923

send the result of dev.off() to a garbage variable

whatever <- dev.off()

Upvotes: 5

Claude
Claude

Reputation: 71

I got a similar problem. My solution was to use dev.off within invisible()

Upvotes: 7

Related Questions