[英]When rendering Rmarkdown from another script, tables not appearing
When I use the knit button in Rstudio the.RMD file renders perfectly into a HTML and all my tables appear.当我在 Rstudio 中使用编织按钮时,.RMD 文件完美地呈现为 HTML 并且我的所有表格都出现了。
My r script that automates my reports looks like the following自动生成报告的 r 脚本如下所示
source("users/some_name/some_file/get_some_data.R")
render("users/some_name/some_file/foo.Rmd")
source("users/some_name/some_file/email_data_report.R")
When run the above r script the tables do not appear in the HTML file produced.当运行上面的 r 脚本时,表格不会出现在生成的 HTML 文件中。
Even when I tried the various table producing packages (base,KableExtra,reactable,DT, etc)即使我尝试了各种表格生成包(base、KableExtra、reactable、DT 等)
If I run the following in my foo.Rmd file -如果我在我的 foo.Rmd 文件中运行以下命令 -
datatable(iris)
I get a table underneath the code chunk in the Rstudio viewer and it appears when I use the knit button but as mentioned not when I call render
for another r script.我在 Rstudio 查看器的代码块下方有一个表格,当我使用编织按钮时它会出现,但正如我为另一个 r 脚本调用
render
时所提到的那样。
Thanks谢谢
Try it with the child
chunk option instead of render()
, eg尝试使用
child
块选项而不是render()
,例如
```{r table, child = 'users/some_name/some_file/foo.Rmd'}
```
Another example, this is how I picuture the RMD-file where df
is created by the data r-file:另一个例子,这是我如何描绘由数据 r 文件创建
df
的 RMD 文件:
```{r}
source("data.R")
```
```{r table}
DT::datatable(df)
```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.