I’m encountering an issue when generating a Word document using Rmarkdown where the out.width
parameter does not seem to affect the size of the images. I tried setting the out.width
parameter to control the width of the images in the Word document.
However, regardless of whether I set out.width to 100%
, 50%
, or 10%
, the images all appear to be the same size in the final output.
Despite setting out.width
to different values, the images in the generated Word file all appear to be the same size.
I have already tried various methods from the following resources, but none of them resolved the issue:
1./questions/32977047/knitr-ignoring-width-and-out-width-options
2./questions/51011490/knitr-not-displaying-graph-when-out-width-or-out-height-set
3.https://github.com/yihui/knitr/issues/1477
4.https://benjaminlouis-stat.fr/en/blog/2020-05-21-astuces-ggplot-rmarkdown/
5.https://bookdown.org/yihui/rmarkdown-cookbook/figure-size.html
Here is my Rmarkdown document and code:
---
title: ""
author: ""
date: ""
output:
officedown::rdocx_document
---
```{r, include=FALSE}
library(tidyverse)
```
```{r, fig.width=7, fig.height=5, out.width="100%"}
# fig.width=7, fig.height=5, out.width="100%"
mtcars %>%
ggplot(aes(x = mpg, y = cyl))+
geom_point()
```
```{r, fig.width=7,fig.height=5, out.width="50%"}
# fig.width=7,fig.height=5, out.width="50%"
mtcars %>%
ggplot(aes(x = mpg, y = cyl))+
geom_point()
```
```{r, fig.width=7,fig.height=5, out.width="10%"}
# fig.width=7,fig.height=5, out.width="10%"
mtcars %>%
ggplot(aes(x = mpg, y = cyl))+
geom_point()
```