add and resize a local image to a .Rmd file in RStudio that will produce a pdf

不问归期 提交于 2019-12-03 05:32:12

From @tmpname12345

You can use raw latex to include a figure in pdf_output: \includegraphics[width=250pt]{path/file.png}

You can also specify the size of the image like so:

![](filepath\file.jpg){ width=50% }

The width and height attributes on images are treated specially. When used without a unit, the unit is assumed to be pixels. However, any of the following unit identifiers can be used: px, cm, mm, in, inch and %. There must not be any spaces between the number and the unit.

Source: Pandoc's RMarkdown Documentation - Images

A longer example with latex.

\begin{figure}
\includegraphics[width=250pt]{../images/pricePlot2006_1.5.png}
\caption{Prices through time.}\label{fig:1}
\end{figure}

Other figures created in the .Rmd are numbered automatically.

```{r namedBlock, fig.cap = "Lots of cars."}
plot(mtcars)
```
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!