生成HTML时如何使用rmarkdown删除输出消息, [英] how to remove output messages with rmarkdown when generating HTML ,

查看:128
本文介绍了生成HTML时如何使用rmarkdown删除输出消息,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些简单的rmarkdown代码,可以生成一些HTML.当我运行此代码时,我的控制台中将获得一堆输出,如下所示.

I have some simple rmarkdown code that generates some HTML. When I run this code I get a bunch of output in my console that looks like this below..

| ......... | 14% 没有R代码的普通文字

|......... | 14% ordinary text without R code

| ................... | 29% 标签:unname-chunk-1(带有选项) 清单2 $结果:chr"asis" $ echo:logi为假

|................... | 29% label: unnamed-chunk-1 (with options) List of 2 $ results: chr "asis" $ echo : logi FALSE

| ..................................... | 43% 没有R代码的普通文字

|............................ | 43% ordinary text without R code

| .............................................. | 57% 标签:unname-chunk-2(带有选项) 清单2 $结果:chr"asis" $ echo:logi为假

|..................................... | 57% label: unnamed-chunk-2 (with options) List of 2 $ results: chr "asis" $ echo : logi FALSE

| .............................................. | 71% 没有R代码的普通文字

|.............................................. | 71% ordinary text without R code

| .............................................. ..... | 86% 标签:unname-chunk-3(带有选项) 清单2 $结果:chr"asis" $ echo:logi为假

|........................................................ | 86% label: unnamed-chunk-3 (with options) List of 2 $ results: chr "asis" $ echo : logi FALSE

| .............................................. ................... | 100% 内联R代码片段

|.................................................................| 100% inline R code fragments

这是生成此输出的代码.

Here is the code that generates this output ..

---
output:
  html_document:
    theme: null
    highlight: null
    css: src/bootstrap.css
---
<link href="src/style.css" rel="stylesheet">

<div id="page">

<h3 id="title-style"> Identification of Respiratory Tract Pathogens by Unbiased Sequencing </h3>

  <p id="inline">Patient: </p>
  <p id="inline">Date of Birth: </p>
  <p id="inline">Gender: </p>
  <p id="inline">Physician: </p>
  <p id="inline">Client: </p>
  <p id="inline">Client Address: </p>

<div id="logo2-lp">
  ![logo](src/logo.png)
</div>

<div id="spacer"></div>

<h3 id="header-style-vir"> Detected Pathogens </h3>
<table id="table-style-vir">
<tr>
 <td>
```{r results='asis', echo=FALSE}
  library(xtable)
  print(xtable(pathogens_table2[c(1:nrow(pathogens_table2)),c(4:10)]),type='html',include.rownames=FALSE)
```
 </td>
</tr>
</table>

<h3 id="header-style-vir"> Evidence for Detection </h3>

<div id="font-style-text">
<font size=1 >
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
</font>
</div>


</div>

我尝试向嵌入式R代码添加选项,例如warning = FALSE,message = FALSE,error = FALSE,results ='HIDE',echo = FALSE或所有这些的组合,但均未成功.调用markdown文件时,我也尝试过使用此代码.

I’ve tried adding options to the embeded R code such as warning=FALSE, message=FALSE, error=FALSE, results=‘HIDE’, echo=FALSE or a combination of all of these with no success. I’ve also tried this code when calling the markdown file..

 suppressMessages(rmarkdown::render("markdown_file.Rmd", output_file = "output.html"))

那也不能给我期望的结果.运行rmarkdown文件时,如何将输出完全删除到控制台?

That doesn’t give me the results I’m expecting either. How to I completely remove output to the console when running rmarkdown files?

推荐答案

除了Roman使用render()选项的解决方案,您还可以修改文件顶部附近的块中的opts_knit设置,例如:

In addition to Roman's solution using render() options, you can also modify the opts_knit settings in a chunk near the top of the file, e.g.:

```{r}
opts_knit$set(progress=FALSE, verbose=FALSE)
```

这样,即使您自己不直接致电render(),进度也将被隐藏.

This way the progress will be hidden even if you are not directly calling render() yourself.

这篇关于生成HTML时如何使用rmarkdown删除输出消息,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆