【问题标题】:R: How to knit pdf and only printing output but suppress messages without `suppressMessages`?R:如何编织 pdf 并且只打印输出但在没有 `suppressMessages` 的情况下抑制消息?
【发布时间】:2020-05-29 04:49:43
【问题描述】:
---
title: 'title'
author: "author"
output: pdf_document
---

考虑这个函数:

doSomething <- function() {
  message("a message")
  2
}

如果我把它放在 R Markdown 文档中:

doSomething ()

然后,PDF 中的输出将同时包含“一条消息”和从 RStudio 编织的值 2。如何在不使用suppressMessage 函数的情况下抑制“消息”?

【问题讨论】:

  • 添加块选项message=FALSE.

标签: r knitr


【解决方案1】:
```{r, message=FALSE}
doSomething ()
```

请参阅https://yihui.org/knitr/options/ 了解更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-18
    • 1970-01-01
    • 1970-01-01
    • 2018-08-23
    • 1970-01-01
    • 1970-01-01
    • 2013-04-25
    相关资源
    最近更新 更多