简体   繁体   中英

Can't suppress error message in R Markdown?

I'm making a tutorial using RMarkdown and I can't suppress the error message I'm getting. The reason I'm suppressing the error is because the code I'm running requires an API key and I'm intentionally leaving it out. I just want to display the code, I know it won't work since I'm not using real API key:

```{r results='hide', error=TRUE, warning=FALSE, message=FALSE}
token <- "xxxxxxxxxxxxxxxxxxxxxxxxxxx"  #this is your secret token
url <- "myurl.com" #this is your URL
 

result <- postForm(
  uri=url, #pass in url 
  token=token, #pass in token
  content='record',
  format='csv',
  type='flat'
)

```

I have message=FALSE but the error messages are still showing up when I knit to HMTL? How can I simply display the code above. Thanks in advance.

Use {r eval = FALSE} . This will stop the code from running.

Here is the code:

```{r eval = FALSE}
token <- "xxxxxxxxxxxxxxxxxxxxxxxxxxx"  #this is your secret token
url <- "myurl.com" #this is your URL
 

result <- postForm(
  uri=url, #pass in url 
  token=token, #pass in token
  content='record',
  format='csv',
  type='flat'
)

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM