4

so i thought this was super simple. I am using

![MissleadingPieChart]
(https://technaverbascripta.files.wordpress.com/2014/04/y-axis3.png)

It gives me this error and I have no idea what is wrong.

Error: unexpected '[' in "!["
packerfan
  • 41
  • 1
  • 1
  • 4
  • 1
    Works fine for me. Make sure you don't have a linebreak between the terms in angular and normal brackets. So it should be `![MissleadingPieChart](https://technaverbascripta.files.wordpress.com/2014/04/y-axis3.png)`. – Maurits Evers Oct 24 '17 at 02:55
  • I have tried the exact line of code on other peoples computers and it works fine. I had them type it in and run it then copy and paste it and send to me. I then put it in mine and it does the same errors! – packerfan Oct 24 '17 at 03:15
  • That suggests something else is wrong. You should open a new RMarkdown HTML document in RStudio, include the image at the bottom, and knit the document. If this works (and it should), the source of your error lies elsewhere. – Maurits Evers Oct 24 '17 at 03:21
  • Possible duplicate of [Insert picture/table in rmarkdown](https://stackoverflow.com/questions/25166624/insert-picture-table-in-rmarkdown) – jay.sf Oct 24 '17 at 08:34
  • @jaySf Not sure this is a duplicate. OP seems to know about how to include images in Rmd, but experiences an error. – Maurits Evers Oct 26 '17 at 03:24
  • Look like you have put this line in a chunk? – Stéphane Laurent Aug 01 '18 at 10:23

2 Answers2

13

I found that working with the following is better than the 'out-of-the-box' shorthand link-like command in rmarkdown (i.e. ![alt-Text-for-figure](url-or-folder-location). On top, it gives you some options to control the output to your liking working with a classical code chunk (e.g. out.width).

```{r figurename, echo=FALSE, fig.cap="my caption", out.width = '90%'}
knitr::include_graphics("figurename.png")
```
Ray
  • 2,008
  • 14
  • 21
0

I had this problem too. I was hitting ctrl+enter and running it in console instead of pressing ctrl+shift+K to knit it to a html file.

  • It's more a comment than an answer. Maybe you don't have reputation enough to comment but post it as an answer isn't the way. Your answer can be downvoted which will keep you from earning reputation to interact further. – Alberson Miranda Apr 05 '23 at 16:18