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?
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)
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With