带有R Markdown的YAML中的错误 [英] Error in YAML with R Markdown
问题描述
我有以下名为test.Rmd
的R Markdown脚本:
I have the following R Markdown script called test.Rmd
:
---
params:
results:
value: !r mtcars
---
```{r setup, echo=FALSE, include=FALSE}
df <- params$results
knitr::kable(df)
```
当我在OpenCPU中运行以下命令时:
When I run the following in OpenCPU:
library(rmarkdown)
library(knitr)
rmarkdown::render("test.Rmd", output_format = "html_document")
yaml :: yaml.load中的错误(yaml,handlers = knit_params_handlers(evaluate = valuate),: 未使用的参数(eval.expr = TRUE)
Error in yaml::yaml.load(yaml, handlers = knit_params_handlers(evaluate = evaluate), : unused argument (eval.expr = TRUE)
我安装了不同版本的YAML,但并没有解决问题.
I installed different versions of YAML and it didn't fix the problem.
推荐答案
我也花了一些时间来解决此问题.看来新的knitr
需要yaml
2.2.0及更高版本.
I took a while to fix this as well. It seems the new knitr
needs a version of yaml
2.2.0 and above.
@ScientificProgrammer在github上的帮助 https://github .com/viking/r-yaml/issues/56#issuecomment-441394840 帮助了我.解决方案是在标准R而非RStudio 中使用devtools安装新软件包.我确实收到了一些编译器错误消息,但它似乎可以正常工作.所以不要让那让你失望.
This help from @ScientificProgrammer on github here https://github.com/viking/r-yaml/issues/56#issuecomment-441394840 helped me. The solution was to install the new package using devtools from within standard R not RStudio. I did get some compiler error messages but it seemed to work. So don't let that put you off.
因此在标准R中,假设您拥有devtools
包
So inside Standard R assuming you have the devtools
package
library(devtools)
devtools::install_github("viking/r-yaml")
我在下面完整地复制了他们的答案,以帮助人们在链接断开的情况下:
I am copying their answer over in full below to help people in case the link breaks:
如果有帮助,我在遇到IndrajeetPatil时会遇到相同的问题 我试图从内部运行devtools :: install_github("viking/r-yaml") RStudio.如果我从内部运行install.packages("viking/r-yaml") RStudio,问题已解决.
In case it helps, I was having the same problem as IndrajeetPatil when I tried to run devtools::install_github("viking/r-yaml") from within RStudio. If I ran install.packages("viking/r-yaml") from within RStudio, the problem was resolved.
但是,当我退出RStudio并运行时 标准R中的devtools :: install_github("viking/r-yaml") 客户端,我仍然收到相同的编译器警告,但是问题 也走了.
However, when I exited RStudio and ran devtools::install_github("viking/r-yaml") from within the standard R client, I still received the same compiler warnings, but the problem also went away.
P.S.另一种对某些人有用的流行解决方案是完全删除yaml
目录,例如使用Windows资源管理器.重新启动RStudio Ctrl + Shift + F10,然后重新安装yaml程序包.这对我不起作用,因为它一直只给我2.1.18版本.
P.S. Another popular solution that helped some people was to delete the yaml
directory completely e.g. using Windows Explorer. Restart RStudio Ctrl + Shift + F10, and then re-install yaml package. That did not work for me as it kept giving me just 2.1.18 version.
这篇关于带有R Markdown的YAML中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!