Images from R are instantly included into (R) markdown files, and the same applies for blogdown posts.
x <- 1:10 plot(x)
However, for external images - such as photos - things are more complicated. First, all is still fine, if an image is found on some URL/server on the internet:
Of course, one can apply direct markdown syntax for including external images:
Now assume we are in an R project that gives the base for a blogdown blog. Next, assume this is the relative path to the image:
img_path <- "/images/textmining/tidytext-crop.png"
Note the leading slash - without the slash it will not work.
This folder itself is found under
static in the project root,
within blogdown folder.
BTW, the project root can be found like this:
here::here() #>  "/Users/sebastiansaueruser/Documents/Publikationen/blog_ses/data_se"
Now, let’s try to plot it using the following code:
Note that we reduce the
width of the image to 20%.
There’s a nice addin to RStudio which helps inserting external images, it’s called insert image add in. Very useful.
Now, let’s try the path as defines by
img_path to render the image again:
Worked out 🎉!