10

I'm creating a presentation in RStudio (.Rpres). I have a figure that is too large and extends beyond the screen. How can I reduce it?

Too big, need to reduce size

Figure 1
========================================================
![alt text](fig1)
Cyrus Mohammadian
  • 4,982
  • 6
  • 33
  • 62
Glen
  • 1,722
  • 3
  • 18
  • 25
  • This is a naive comment. Are you able to write pure html into .Rpres files like you can using Rmd and knitr? If so, you could just use the `` tag and specify your `height` argument instead of using the markdown syntax for images. – Tad Dallas Apr 16 '15 at 03:49

2 Answers2

9

This should work:

<div align="center">
<img src="fig1.jpg" width=800 height=600>
</div>

Simply adjust the width and height as required.

Grant
  • 1,536
  • 13
  • 25
2

You can use

```{r, echo=FALSE}
knitr::include_graphics(path,  dpi = NULL)
```

in a chunk and then set image height and width options in the chunk options. This should work with all output formats.

JD Long
  • 59,675
  • 58
  • 202
  • 294
Richard Telford
  • 9,558
  • 6
  • 38
  • 51
  • none of it... I don't think you're addressing the situation the OP asked about: 1) rprez files don't go through knitr 2) they are HTML, not PDF I suspect your answer would work for RMarkdown files that are being rendered as other slide types, but not *.rpres – JD Long May 06 '18 at 15:37
  • `include_graphics` works with rpres files. Doesn't matter if the output is html or pdf or whatever. – Richard Telford May 06 '18 at 15:53
  • are you sure you are not thinking of ioslides or one of the other (many) slide formats that you can create with RMarkdown? What you propose will likely work with many of them, but not with the specific *.rpres format. – JD Long May 06 '18 at 21:46
  • although my comment above where I say "rpres files don't go through knitr" is completely wrong. So I may be wrong about other things as well! I'm testing right now to make sure... – JD Long May 06 '18 at 21:50
  • aaaaand you were right.. Since rpres presentations are only really useful as HTML, I think the auto_pdf example should be dropped. And it should be noted that this goes in a code chunk with echo=FALSE flipped. – JD Long May 06 '18 at 21:54