4

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.

Michael Harper
  • 14,721
  • 2
  • 60
  • 84
DanMed
  • 61
  • 1
  • 4
  • Can you refine the question as it is currently difficult to work out where this could be going wrong. Some tips: 1) Use a dataset which others can recreate such as the `mtcars` dataset. 2) Does the 'EXPORT' function need to be defined or can you just run the `render` functions normally? 3) Change the file path to remove the `system.file` path and just create a relative path. In doing these changes, you may even discover the problem yourself. – Michael Harper Jul 27 '18 at 09:02
  • See my edits. By my understanding that should still show the error you are seeing. If it is not correct though, rollback the changes. – Michael Harper Jul 27 '18 at 09:09
  • Yes it throw the same error, even without the parameter: `params = list(results = mtcars)`. If i write in the R markdown script `params: results: !r mtcars` and i execute `rmarkdown::render("mtcarsexample.Rmd", output_format = "html_document")` i get the same error – DanMed Jul 27 '18 at 09:37
  • Okay, I further edited your question. Please use this as an example of how to slim-down your questions in the future :) Are you sure all your packages are up to date? `install.packages("rmarkdown")` etc. – Michael Harper Jul 27 '18 at 09:51
  • Yes thx!!! Finally I have solved it. My installation of the yaml-2.1.14 package was corrupted. I have had to delete it manually and I have installed version 2.1.19. Since the latest version 2.2.0. also gave me problems – DanMed Jul 27 '18 at 10:30

2 Answers2

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.

micstr
  • 5,080
  • 8
  • 48
  • 76
1
  1. Install the devtools package from CRAN.
  2. In R, run the following:

    library(devtools)

    install_github('viking/r-yaml')

micstr
  • 5,080
  • 8
  • 48
  • 76
  • Welcome to stackoverflow. Your answer will be most useful if you explain it more completely. – Simon.S.A. Dec 19 '18 at 19:22
  • 1
    Attempted to `install_github('viking/r-yaml')`, which not only failed, but has now apparently corrupted by RStudio installation so that on startup, I get `Error in .Call(C_unserialize_from_yaml, string, as.named.list, handlers, : Incorrect number of arguments (8), expecting 4 for 'unserialize_from_yaml'` multiple times. I also seem to be unable to reinstall the original `yaml`. More explanation to the answer would have been good. – jhchou Jan 26 '19 at 12:21