将列表参数传递给 rmarkdown 文件 (.Rmd)
Pass List argument to rmarkdown file (.Rmd)
我正在使用 rmarkdown 生成 HTML 报告。我想通过 render
方法传递表的列表,但它抛出一个错误:
Error in UseMethod("as.html") :
no applicable method for 'as.html' applied to an object of class "character"
代码片段:
---
params:
tables: !r
---
```{r results='asis', echo=FALSE}
for(i in as.list(params$tables)){
cat("######", as.html(i), "\n")
}
```
请提出解决方法。
感谢您的帮助!
为表提供默认值,例如
tables: !r "whatever"
我在文档中找不到要求,但看起来像“”这样的空字符串不起作用。
添加对 htmltools 的引用
library(htmltools)
没有函数as.html,在htmltools或shiny中只有HTML:
HTML(i)
我正在使用 rmarkdown 生成 HTML 报告。我想通过 render
方法传递表的列表,但它抛出一个错误:
Error in UseMethod("as.html") :
no applicable method for 'as.html' applied to an object of class "character"
代码片段:
---
params:
tables: !r
---
```{r results='asis', echo=FALSE}
for(i in as.list(params$tables)){
cat("######", as.html(i), "\n")
}
```
请提出解决方法。
感谢您的帮助!
为表提供默认值,例如
tables: !r "whatever"
我在文档中找不到要求,但看起来像“”这样的空字符串不起作用。
添加对 htmltools 的引用
library(htmltools)
没有函数as.html,在htmltools或shiny中只有HTML:
HTML(i)