I have two same size images, and I would like to insert in for knitting to a PDF document, one with left one with right alignment.
I have used
---
title: "Untitled"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Testing
![](meme.jpg){width=5%, align="left"} ![](meme.jpg){width=5%,align="right"}
but it does not seem to work.
What am I doing wrong?
Markdown does not include alignment but you can use LaTeX's \hfill:
---
title: "Untitled"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Testing
![](meme.jpg){width=5%} \hfill ![](meme.jpg){width=5%}
I am using R Markdown as per the below:
---
title: title
author:
- Name1:
email: email
institute: med
correspondence: yes
- name: name2
institute: med
date: date
bibliography: ref_file.bib
bib-humanities: true
output:
pdf_document:
includes:
in_header: header.tex
number_sections: yes
toc: no
pandoc_args:
- --lua-filter=scholarly-metadata.lua
- --lua-filter=author-info-blocks.lua
word_document:
toc: no
pandoc_args:
- --lua-filter=scholarly-metadata.lua
- --lua-filter=author-info-blocks.lua
html_document:
toc: no
df_print: paged
header-includes: \usepackage{amsmath}
institute:
- med: etc etc
---
#RN36382 defined...
My ref_file.bib shows:
#article{RN36382,
author = {van der Laan, M. J.},
title = {Statistical Inference for Variable Importance},
journal = {The International Journal of Biostatistics},
volume = {2},
number = {1},
year = {2006},
type = {Journal Article}
}
My pdf output is:
"Laan (2006) defined ..." , however, I was expecting "van der Laan (2006) defined..."
How can I fix this? Thanks!
You should add double brackets ;)
...
author = {{van der Laan, M. J.}}
...
When I create a html Presentation with slidy (Rmarkdown and Rstudio) and knit it to an html, any latex equation are not displayed properly if I am offline.
How can I change that?
---
title: "MinimalExample"
author: "keks"
date: "9 9 2019"
output: slidy_presentation
---
## R Markdown
$\pi = \frac{ a }{ b }$
```{r}
plot(seq(1,19))
```
Here is a minimal example, where the $xyz$ Equation is only properly shown, if I am online.
I have noticed this issue when knitting all file types (html, pdf, word). To make sure there's not an issue specific to my program, I went ahead and ran the default .rmd file you get when you create a new markdown. In each case, it does knit correctly, but I always see this at the end. I have searched online and here but cannot seem to 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 the 7 and "
I'm not sure where Line 6, column 19 is, but that line is the dashes at the bottom
Any ideas?
Thank you.
I get this error when trying to add a table of contents to the YAML:
title: "STAC2020 Data Analysis"
date: "July 16, 2020"
output: html_notebook:
toc: true
However, if I put html_notebook: on to a separate line then I don't get the error:
title: "STAC2020 Data Analysis"
date: "July 16, 2020"
output:
html_notebook:
toc: true
I do not know why this formatting makes a difference, but it allowed my document to knit and with a table of contents.
I realize this question has gone unanswered for awhile, but maybe someone can still benefit. I had the same error message and I realized I had an extra header command in my yaml. I can't reproduce your exact error, but I get the same message with different line/column references with:
---
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 column 15 seems to refer to the second colon after the second "output".
I received this error when there was an indentation in the wrong place:
For example, the indentation before header-includes as seen in the example code below caused the error
---
title: "This is a title"
author: "Author Name"
header-includes:
.
.
.
---
When you remove the indentation, the following code below did not produce the error:
---
title: "This is a title"
author: "Author Name"
header-includes:
.
.
.
---
Similarly to Tim Ewers I also got this error when I added a TOC to the YAML:
title: "My title"
date: "April 1, 2020"
output:
pdf_document: default
toc: true
html_document: paged
However, the solution I found was to remove "default", this allowed me to knit the document without an error:
title: "My title"
date: "April 1, 2020"
output:
pdf_document:
toc: true
html_document: paged
I guess this error happens on your content instead of your yaml block.
Because there is no extra content display so I will 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 is 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
The errors happens at line 8. Because there is a key-value pair not at yaml block.
yaml.load is not enough smart for me.
The temporal solution for me is 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"
I had a similar problem and made a request in the YAML and rticles help pages:
https://github.com/viking/r-yaml/issues/92
https://github.com/rstudio/rticles/issues/363
I know this is a 5 year old question but I just got this same error as I was missing a colon
---
title: ''
output:
pdf_document
includes:
before_body: before_body.tex
---
should have been
---
title: ''
output:
pdf_document:
includes:
before_body: before_body.tex
---
and while that doesn't strictly answer the example given, I hope it will help future sufferers of this error message.
I have Facebook likes saved in a table (they're in a string) and do the following in the console to return the likes using the like method for the user model:
User.first.likes
=> "--- !seq:Koala::Facebook::GraphCollection \n- name: Rome Sweet Rome\n category:
Book\n id: \"136333439795671\"\n created_time: 2011-09-05T12:03:09+0000\n- name:
Drawn Together\n category: Tv show\n id: \"8694990902\"\n created_time:
2008-10-03T10:39:46+0000\n"
Below it is in YAML:
y User.first.likes
--- |
--- !seq:Koala::Facebook::GraphCollection
- name: Rome Sweet Rome
category: Book
id: "136333439795671"
created_time: 2011-09-05T12:03:09+0000
- name: Drawn Together
category: Tv show
id: "8694990902"
created_time: 2008-10-03T10:39:46+0000
=> nil
I want the end result to give me something like:
>> ["Rome sweet Rome", "Drawn Together"]
Split the string into separate lines, delimited by the \n character (or if it comes across as the string "\n", use double-quotes to delimit on that string)
like_elements = User.first.likes.split("\n") # <- String, not character, delimited version
=> ['id: "136333439795671"', 'created_time: 2011-09-05T12:03:09+0000", "- name: Drawn Together" ... etc.]
Then collect all elements that start with "- name: " into their own array:
name_elements = like_elements.select{|s| s.start_with?("- name: ")}
=> ["- name: Drawn Together", "- name: Rome sweet Rome"]
Then take each of the elements in name_elements and strip out the leading "- name: " text, and remove leading an trailing whitespace
names_of_likes_only = name_elements.collect{|n| n.gsub("- name: ", "").strip}
=> ["Drawn Together", "Rome sweet Rome"]