带有 R Markdown 的 YAML 错误 [英] Error in YAML with R Markdown

查看:24
本文介绍了带有 R Markdown 的 YAML 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下称为 test.Rmd 的 R Markdown 脚本:

---参数:结果:值:!r mtcars---```{r 设置,echo=FALSE,include=FALSE}df <- 参数$结果knitr::kable(df)```

当我在 OpenCPU 中运行以下命令时:

库(rmarkdown)图书馆(编织者)rmarkdown::render("test.Rmd", output_format = "html_document")

<块引用>

yaml::yaml.load(yaml, handlers = knit_params_handlers(evaluate = evaluate), 中的错误:未使用的参数(eval.expr = TRUE)

我安装了不同版本的 YAML,但没有解决问题.

解决方案

我也花了一些时间来解决这个问题.看来新的 knitr 需要 yaml 2.2.0 及以上版本.

来自@ScientificProgrammer 在 github 上的帮助 https://github.com/viking/r-yaml/issues/56#issuecomment-441394840 帮助了我.解决方案是使用 standard R 而不是 RStudio 中的 devtools 安装新软件包.我确实收到了一些编译器错误消息,但它似乎有效.所以不要让它让你失望.

所以在标准 R 中假设你有 devtools

库(开发工具)devtools::install_github("viking/r-yaml")

我将他们的答案全文复制到下面,以帮助人们以防链接断开:

<块引用>

如果有帮助,我遇到了和 IndrajeetPatil 一样的问题我试图从内部运行 devtools::install_github("viking/r-yaml")工作室.如果我从内部运行 install.packages("viking/r-yaml")RStudio,问题已解决.

但是,当我退出 RStudio 并运行时标准 R 中的 devtools::install_github("viking/r-yaml")客户端,我仍然收到相同的编译器警告,但问题也走了.

附:另一个帮助某些人的流行解决方案是完全删除 yaml 目录,例如使用 Windows 资源管理器.重启RStudio Ctrl + Shift + F10,然后重新安装yaml包.这对我不起作用,因为它一直只给我 2.1.18 版本.

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.

解决方案

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.

这篇关于带有 R Markdown 的 YAML 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆