Javi_VM Javi_VM - 1 year ago 79
R Question

R Bookdown image disappears

I am having an issue with bookdown, not sure the reason why.

When add images (these are files, so I use knitr::include_graphics) like this:

# This is a minimal example

I want the image "mas.gif". Where is it?
```{r mas, echo=F, fig.cap="image", ref.label="fig:mas"}
knitr::include_graphics("mas.gif")
```

Hmmm...no clue!


The chunk just disappears in the epub, md, tex and pdf files.

What could be wrong? It used to work some while ago...

Answer Source

Just remove , ref.label="fig:mas", like this

# This is a minimal example

I want the image "mas.gif". Where is it?
```{r mas, echo=F, fig.cap="image"}
knitr::include_graphics("mas.gif")
```

Hmmm...no clue!

See the documentation by bookdown package's author:

If we assign a figure caption to a code chunk via the chunk option fig.cap, R plots will be put into figure environments, which will be automatically labeled and numbered, and can also be cross-referenced. The label of a figure environment is generated from the label of the code chunk, e.g., if the chunk label is foo, the figure label will be fig:foo (the prefix fig: is added before foo). To reference a figure, use the syntax \@ref(label), where label is the figure label, e.g., fig:foo.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download