I was working on an interesting article about APR using Rmarkdown in RStudio. I thought it would be more convincing to include some images. Then I realized the default syntax  might not be enough because the size might go crazy if you are not careful enough.
As you can see from this stackoverflow article, “markdown has no syntax for specifying the dimensions of an image”. Instead of writing your own html img tag, I prefer the solution of writing some R code to customize the size.
As you can see, using library png and grid will easily read in your image and display that on the screen.
In your Rmarkdown code, simply specify the figure dimensions in the r tag will customize your image to whatever you want. 🙂
“`{r fig.width=2, fig.height=2}
library(png)
library(grid)
img <- readPNG(“images/apr1.png”)
grid.raster(img)
“`
“`{r fig.width=4, fig.height=4}
library(png)
library(grid)
img <- readPNG(“images/apr1.png”)
grid.raster(img)
“`