将R代码隐藏在Rmarkdown/knit中并仅显示结果 [英] Hiding the R code in Rmarkdown/knit and just showing the results

查看:433
本文介绍了将R代码隐藏在Rmarkdown/knit中并仅显示结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的R Markdown文档中,有时我只想生成一个报告而不显示实际代码(特别是在将其发送给老板时).如何隐藏R代码并仅显示图形和结果?

In my R Markdown documents, I sometimes want to just generate a report without showing the actual code (specially when I send it to my boss). How can I hide the R code and just show the graph and results?

例如:

---
output: html_document
---

```{r fig.width=16, fig.height=6}
plot(cars)
```

这同时显示了命令和图解.如何从HTML报告中删除命令?

This shows both the commands and the plot. How can I remove the commands from my HTML report?

推荐答案

当然,只要做

```{r someVar, echo=FALSE}
someVariable
```

显示一些(先前计算的)变量someVariable.或运行可打印pp等的代码

to show some (previously computed) variable someVariable. Or run code that prints etc pp.

为了绘图,我有例如

### Impact of choice of ....
```{r somePlot, echo=FALSE}
plotResults(Res, Grid, "some text", "some more text")
```

其中绘图功能plotResults来自本地程序包.

where the plotting function plotResults is from a local package.

这篇关于将R代码隐藏在Rmarkdown/knit中并仅显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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