Topic 3: Adding images

TO UPDATE THIS PAGE: Open and edit the topic_3.Rmd file, in the project root, to delete this placeholder text and customize with your own!

Where should I save my images?

Drop images you want to include on your site into the existing img folder within your R Project (or make your own folder for images, set up a subfolder structure, etc.) - as long as you can easily point to them within your project.

How do I make images show up on my site?

There are a bunch of ways to add images in an R Markdown document (see more examples from the R Markdown Cookbook here).

I recommend using knitr::include_graphics("path_to_image").

For example, if there is an image saved as cool_dogs.jpg in the img folder, then you can add this to your R Markdown document by adding (within a code chunk):


```{r, echo = FALSE}
  knitr::include_graphics("img/cool_dogs.jpg")
```

You can also update the size of the image, add a caption, etc. by updating the code chunk header, e.g.:


```{r, echo = FALSE, out.width = "50%", fig.cap = "Some cool dogs!"}
  knitr::include_graphics("img/cool_dogs.jpg")
```

For example, the image usgs_sat.jpeg is in the img folder of this template. I can have it show up here by include a code chunk that looks like this:


```{r, echo = FALSE, out.width = "80%", fig.cap = "USGS image of Mississippi River."}
  knitr::include_graphics("img/usgs_sat.jpeg")
```

Which creates:

USGS image of Mississippi River.

Figure 1: USGS image of Mississippi River.