Instead of having to include the relative path to an image like so:

I would like to bring in an image from the yaml object like so:

where yaml$inputs$R1_ambient contains the full path to the png. However, this does not render the image. Why is that?
CodePudding user response:
I'm not sure which flavour of Rmarkdown you're using (so not sure about yaml$inputs and the label cross-reference). However, my solution should work nevertheless.
You can use knitr::include_graphics in an R chunk to make use of the parameterised path:
---
title: "Test"
date: "4/4/2022"
output: html_document
params:
R1_ambient: "test.png"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Plot
```{r R1amb, echo = FALSE, fig.cap = "R1 Ambient RNA Contamination"}
knitr::include_graphics(params$R1_ambient)
```
