Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Rmarkdown文档中显示帮助函数的输出_R_R Markdown - Fatal编程技术网

如何在Rmarkdown文档中显示帮助函数的输出

如何在Rmarkdown文档中显示帮助函数的输出,r,r-markdown,R,R Markdown,我有一个非常简单的Rmarkdown文档,我使用help函数来获取数据集的概述。当我编织文档时,会打开一个新的浏览器页面,显示帮助调用的结果,而不是在生成的HTML文档中显示帮助调用的结果 如何获取要在html文件中显示的帮助信息 以下是简单的rmarkdown: --- title: "Help not working" author: "Stackoverflow" date: "8/31/2020" output: html_do

我有一个非常简单的Rmarkdown文档,我使用help函数来获取数据集的概述。当我编织文档时,会打开一个新的浏览器页面,显示帮助调用的结果,而不是在生成的HTML文档中显示帮助调用的结果

如何获取要在html文件中显示的帮助信息

以下是简单的rmarkdown:

---
title: "Help not working"
author: "Stackoverflow"
date: "8/31/2020"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(fpp2)
```

#### gold

```{r}
help(gold)
```

我不认为有一个非常明显的方法可以做到这一点——试试这个(类似于Waldi所建议的):

如果有一个更优雅的解决方案,那会很有趣

---
title: "Help not working"
author: "Stackoverflow"
date: "8/31/2020"
output: html_document
---


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(fpp2)
library(forecast)
```

# Example helpfile

```{r, echo = F}
helpfile <- utils:::.getHelpFile(help(gold))
outfile <- tempfile(fileext = ".html")
tools:::Rd2HTML(helpfile, out =outfile)
rawHTML <- paste(readLines(outfile), collapse="\n")
knitr::asis_output(htmltools::htmlPreserve(rawHTML))
```         
---
标题:“帮助不工作”
作者:“Stackoverflow”
日期:“2020年8月31日”
输出:html\u文档
---
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
图书馆(fpp2)
图书馆(预测)
```
#示例帮助文件
```{r,echo=F}

帮助文件提供了以下帮助:@Waldi谢谢。我唯一的问题是html输出是实际的原始html源代码,而不是呈现。可以呈现输出吗?这很有效。是否可以减少字体?是的,这可以通过调整HTML来实现。尝试检查rawHTML中的内容-您将看到这是帮助文件的原始html文本。您需要在需要更改的位置添加特定的附加html标记。