yaml :: yaml.load(...,eval.expr = TRUE)中的错误:在Rmarkdown中使用Shiny时 [英] Error in yaml::yaml.load(..., eval.expr = TRUE) : when using shiny in Rmarkdown

查看:911
本文介绍了yaml :: yaml.load(...,eval.expr = TRUE)中的错误:在Rmarkdown中使用Shiny时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法编译任何具有光泽的.Rmd文档.例如,此五行文档(或任何文档,例如使用File-> New File-> R Markdown ...:Shiny Document创建的文档)

I can't compile any .Rmd document with shiny. For example, this five-line document (or any document, e.g. the one created with File->New File -> R Markdown ... : Shiny Document)

---
title: "Untitled"
output: flexdashboard::flex_dashboard
runtime: shiny
---
End of my very short document.

当我单击运行文档"时,出现此错误.按钮:

I get this error when I click on "Run Document" button:

==> rmarkdown::run('/home/gxd/R-codes/lesson10/tmp.Rmd', shiny_args = list(launch.browser = FALSE), auto_reload = FALSE, dir = '/home/gxd/R-codes/lesson10',  render_args = list(encoding = 'UTF-8'));
Error in yaml::yaml.load(..., eval.expr = TRUE) : 
  Scanner error: while scanning a quoted scalar at line 2, column 8 found unexpected end of stream at line 8, column 15
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load -> <Anonymous>
Execution halted

遵循以下建议: YAML中的RMarkdown错误 我检查了YAML标头中的所有空格和其他特殊符号.一切似乎都是正确的.

Following this advise: RMarkdown error in YAML I checked for all spaces and other special symbols in YAML header. All seems correct.

任何人都知道导致它的原因以及如何解决它?我的会话信息如下:

Anyone knows what causes it and how to fix it? My session info below:

> sessionInfo()
R version 3.6.1 (2019-07-05)
...
>   packageVersion("shiny") 
[1] ‘1.5.0’
>   packageVersion("rmarkdown") 
[1] ‘2.3’
>   packageVersion("knitr") 
[1] ‘1.28’

推荐答案

我发现,如果我创建了New Project,然后又使用Shiny创建了一个新的R Markdown文件,那么编译就可以了.

I've found that if I create New Project, and then I create a new R Markdown file with Shiny, then it compiled just fine.

我必须是我以前的项目目录中的某个文件,它阻止了我的.Rmd与带有闪亮文件的编译.我那里确实有很多其他文件(包括其他带有光泽的.Rmd,没有一个已编译)和各种子目录(我也有带有闪亮的.Rmd文件,并且它们确实在哪里编译).

I must be something that was in my previous project directory that was preventing from compiling my .Rmd with file with shiny. I do have plenty of other files there (including other .Rmd with shiny, none of which compiled) and various sub-directories (where I also have .Rmd files with shiny, and where they DO compile).

但是我仍然没有弄清楚到底是什么引起了问题.我试图删除./Rproj.user和.Rhistory-它没有任何作用.

But I still have not figured what exactly was causing the problem. I tried to delete ./Rproj.user and .Rhistory - it did not have any effect.

因此,我创建了一个新的干净目录,并将上面显示的简单的5行.Rmd文件放入并进行编译.

So I've created a new clean directory and put my simple 5 line .Rmd file shown above and it compiled.

我仍然很想知道问题出在什么地方...

I'm still very curious to understand what was the problem...

更新:
现在我知道问题出在哪里了! -- 在同一个目录中,我有另一个不相关的未完成" .rmd文件. 另一个.Rmd文件的YAML标头的标题中包含未完成(打开)的字符串:

UPDATE:
Now I know where the problem was! - In the same directory I had another unrelated "unfinished" .Rmd file. This other .Rmd file had YAML header with unfinished (open) string in title:

title: "The Header of another Rmd file that was in the same directory

注意,标题"缺少标题.

修复后,我现在可以在同一目录中编译任何其他.Rmd.
但是,如果我不固定它,我将不会在同一目录中编译任何其他.Rmd! 那有点奇怪,但事实就是如此.

Once I fixed it, i can now compile any other .Rmd in the same directory.
But if i leave it unfixed, I wil lnot be to compile ANY other .Rmd in the same directory! That;s kinda strange, but that's how it is.

这篇关于yaml :: yaml.load(...,eval.expr = TRUE)中的错误:在Rmarkdown中使用Shiny时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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