Error in YAML with R Markdown

三世轮回 提交于 2019-12-29 09:00:39

问题


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)
```

When I run the following in OpenCPU:

library(rmarkdown)
library(knitr)
rmarkdown::render("test.Rmd", output_format = "html_document")

Error in yaml::yaml.load(yaml, handlers = knit_params_handlers(evaluate = evaluate), : unused argument (eval.expr = TRUE)

I installed different versions of YAML and it didn't fix the problem.


回答1:


  1. Install the devtools package from CRAN.
  2. In R, run the following:

    library(devtools)

    install_github('viking/r-yaml')




回答2:


I took a while to fix this as well. It seems the new knitr needs a version of yaml 2.2.0 and above.

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.

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:

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.

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. 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.



来源:https://stackoverflow.com/questions/51553603/error-in-yaml-with-r-markdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!