Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
566 views
in Technique[技术] by (71.8m points)

html - 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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'
)

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...