R Markdown YAML"扫描仪错误:映射值..."

Sco*_*son 7 yaml r-markdown

在编织所有文件类型(html,pdf,word)时我注意到了这个问题.为了确保没有特定于我的程序的问题,我继续运行您在创建新的降价时获得的默认.rmd文件.在每种情况下,它都正确编织,但我总是在最后看到这一点.我在网上和这里搜索过,但似乎无法找到解释

Error in yaml::yaml.load(string, ...) : 
  Scanner error: mapping values are not allowed in this context at line 6, column 19
Error in yaml::yaml.load(string, ...) : 
  Scanner error: mapping values are not allowed in this context at line 6, column 19
Error in yaml::yaml.load(string, ...) : 
  Scanner error: mapping values are not allowed in this context at line 4, column 22
Run Code Online (Sandbox Code Playgroud)

这是我的默认YAML

---
title: "Untitled"
author: "Scott Jackson"
date: "April 20, 2017"
output: word_document
---
Run Code Online (Sandbox Code Playgroud)

第4行第22列是7和"我不确定第6行第19列的位置"之间的空间,但该行是底部的破折号

有任何想法吗?

谢谢.

小智 9

尝试向 YAML 添加目录时出现此错误:

title: "STAC2020 Data Analysis"
date: "July 16, 2020"
output: html_notebook:
  toc: true
Run Code Online (Sandbox Code Playgroud)

但是,如果我放在html_notebook:单独的行上,则不会收到错误消息:

title: "STAC2020 Data Analysis"
date: "July 16, 2020"
output:
  html_notebook:
    toc: true
Run Code Online (Sandbox Code Playgroud)

我不知道为什么这种格式会有所不同,但它允许我的文档编织并带有目录。

  • 令人沮丧,因为您发布的“错误”示例基本上是直接从 RMarkdown 备忘单中提取的 (2认同)

use*_*609 7

我意识到这个问题已经有一段时间没有得到解决,但也许有人仍然可以受益.我有相同的错误消息,我意识到我在我的yaml中有一个额外的头命令.我无法重现您的确切错误,但我得到了具有不同行/列引用的相同消息:

---
title: "Untitled"
author: "Scott Jackson"
date: "April 20, 2017"
output: output: word_document
---

Error in yaml::yaml.load(string, ...) : 
  Scanner error: mapping values are not allowed in this context at line 4, column 15
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load_utf8 -> <Anonymous>
Execution halted
Run Code Online (Sandbox Code Playgroud)

第4行第15列似乎是指第二个"输出"之后的第二个冒号.

  • 又一个完全无益且具有误导性的错误消息的例子!它的意思似乎是“你的 YAML 有问题,但不知道是什么”。 (4认同)

Kim*_*ink 6

当在错误的地方有缩进时,我收到了这个错误:

例如,在header-includes下面的示例代码中看到的之前的缩进导致了错误

---
title: "This is a title"
author: "Author Name"
   header-includes:
.
.
.
---
Run Code Online (Sandbox Code Playgroud)

当您删除缩进时,以下代码不会产生错误:

---
title: "This is a title"
author: "Author Name"
header-includes:
.
.
.
---
Run Code Online (Sandbox Code Playgroud)