Reputation: 27
I want to add a picture (.png) to my r markdown file (and I want to knit to PDF). However, I've tried this simple code recommended everywhere but it doesn't work for me:

Because I get the error:
Error: unexpected '[' in "!["
I'm very new to r markdown. I'm not sure what I'm doing wrong - I've already moved the .Rmd file to where the images are which I saw was also recommended but it doesn't seem like that's the issue. I haven't seen anyone else have issues with the "![]" before.
Does anyone have any suggestions on how to fix this?
(Also, knitr::include_graphics("image.png") works for me and yes I could use that but I want to get to the root of the problem above...)
Upvotes: 1
Views: 4359
Reputation: 41260
The image insertion Rmarkdown
syntax doesn't work inside an r
chunck.
In a chunck you can use knitr::include_graphics("image.png")
as mentioned in your post.
This doesn't work :
```{r}

```
Error: unexpected '[' in "
Upvotes: 6