【问题标题】:Can't suppress error message in R Markdown?无法抑制 R Markdown 中的错误消息?
【发布时间】:2021-01-05 21:01:11
【问题描述】:

我正在使用 RMarkdown 制作教程,但无法抑制收到的错误消息。我抑制错误的原因是因为我正在运行的代码需要一个 API 密钥,而我故意将其排除在外。我只是想显示代码,我知道它不会工作,因为我没有使用真正的 API 密钥:

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

```

我有message=FALSE,但是当我编织到 HMTL 时,错误消息仍然出现!我怎样才能简单地显示上面的代码?提前致谢。

【问题讨论】:

  • 第五行(“uri”)有错字吗?应该是“url”吗?

标签: html r r-markdown


【解决方案1】:

使用 {r eval = FALSE} 。这将停止代码运行。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-07
    • 2015-12-20
    • 1970-01-01
    • 2020-09-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-20
    相关资源
    最近更新 更多