John_Ruf
John_Ruf

Reputation: 53

How to properly use fig.align in Rmarkdown?

So the primary issue I'm facing with getting a plot correct in Rmarkdown is that when I try to do so, using the following code (for this code '' is intended to match the traditional ''' used in chunks for Rmarkdown).

``{r fig.align = 'right' Name, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}
#nothing actually here
``

And then when I try to knit, I get the following error


processing file: Writing_Sample_MKD.Rmd
(*) NOTE: I saw chunk options "fig.align = 'right' Name, echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE"
 please go to https://yihui.org/knitr/options
 (it is likely that you forgot to quote "character" options)
Error in parse(text = code, keep.source = FALSE) : 
  <text>:1:28: unexpected symbol
1: alist( fig.align = 'right' Simple
                               ^
Calls: <Anonymous> ... parse_params -> withCallingHandlers -> eval -> parse_only -> parse
Execution halted

I tried a few different variations of fig.align = 'right' including

fig.align = 'right',
fig.align = "right"
fig.align = 'right';'character'
fig.align = 'right':'character

but none of these variations fix the issue. Why does this occur and how can I stop it from happening?

Upvotes: 2

Views: 6728

Answers (1)

Snot
Snot

Reputation: 79

You may delete the "Name" after fig.align='right'. Also, you may add a comma between chunk name and chunk options.

---
title: "test"
author: "test"
date: "10/13/2020"
output: word_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Including Plots

Text1

```{r your_chunk_name, fig.align = 'right', echo=FALSE, message=FALSE, warning=FALSE, paged.print=FALSE}

plot(pressure)
```

Test2

Upvotes: 2

Related Questions