R Markdown YAML "Scanner Error: Display Values ​​..."

I noticed this problem when knitting all types of files (html, pdf, word). To make sure there was no problem in my program, I went ahead and ran the default .rmd file you get when you create a new markdown. In every case it is knitted correctly, but I always see it at the end. I have searched on the internet and here but cannot find an explanation.

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

      

Here is my default YAML

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

      

Line 4, column 22 is the space between 7 and "I'm not sure where line 6, column 19 is, but this line is a dash at the bottom

Any ideas?

Thank.

+5


source to share


2 answers


I realize this question has gone unanswered for a while, but maybe someone else might benefit. I had the same error message and realized that I had an additional header command in my yaml. I cannot reproduce your exact error, but I get the same message with different row / column references:

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

      



Line 4 of column 15 appears to refer to the second colon after the second "output".

+3


source


I'm guessing this error is happening with your content instead of your yaml block. Because there is no additional content display, so I'll give a minimal example.

> library(yaml)
> library(magrittr)
> "
+ ---
+ title: 'This is a title'
+ output: github_document
+ ---
+ 
+ some content
+ " %>% 
+     yaml.load()
$title
[1] "This is a title"

$output
[1] "github_document"

      

It works well. And here's another example.



> "
+ ---
+ title: 'This is a title'
+ output: github_document
+ ---
+ 
+ some content
+ some content: some content
+ " %>% 
+     yaml.load()
Error in yaml.load(.) : 
  Scanner error: mapping values are not allowed in this context at line 8, column 13

      

Errors occur on line 8. Because there is a key-value pair not in the yaml block. yaml.load

not smart enough for me. A workaround for me to just extract all lines above the second ---

.

> text <- "
+ ---
+ title: 'This is a title'
+ output: github_document
+ ---
+ 
+ some content
+ some content: some content
+ "
> library(xfun)
> read_lines(text,n_max = 5) %>% 
+     yaml.load()
$title
[1] "This is a title"

$output
[1] "github_document"

      

0


source







All Articles