Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fig.width and fig.height not working for knitr Word output from R Markdown

For pdf figures, the fig.width and fig.height chunk options are only changing the proportions of the 2"x2" figure in my word document. I can't seem to control the size of the pdf figure as I can with png figures knitted from R Markdown into a word document.

---
title: "Controlling PDF figure size in MS Word output"
output: word_document
---

```{r global_options, include=FALSE}
knitr::opts_chunk$set(fig.path='02_Figs/',  fig.show='asis', dev = 'pdf', 
include=FALSE, warning=FALSE, message=FALSE)
```

# Fig. 1. Small Plot
```{r include=TRUE, echo=FALSE, fig.width=2, fig.height=3, fig.keep='high'}
with(mtcars, plot(mpg~wt))
```

# Fig. 2. Big Plot
```{r include=TRUE, echo=FALSE, fig.width=4, fig.height=6, fig.keep='high'}
with(mtcars, plot(mpg~wt))
```
like image 672
Joe Avatar asked Jun 15 '16 18:06

Joe


1 Answers

Updating to the latest version of Pandoc 1.17.1 solved this problem. Now pdf images display fine.

like image 140
Joe Avatar answered Dec 05 '22 21:12

Joe