without a reprex it is hard to answer your questions but I assume you have this setup as a parameterised report as per the instructions here.
https://shiny.rstudio.com/articles/generating-reports.html
I would suggest setting up this image as a paramater that is passed to the r markdown YAML header, would look like the following.
In your app
somepicture would be added to the parameters.
output$report <- downloadHandler(
# For PDF output, change this to "report.pdf"
filename = "report.html",
content = function(file) {
# Copy the report file to a temporary directory before processing it, in
# case we don't have write permissions to the current working dir (which
# can happen when deployed).
tempReport <- file.path(tempdir(), "report.Rmd")
file.copy("report.Rmd", tempReport, overwrite = TRUE)
# Set up parameters to pass to Rmd document
params <- list(n = 'somepicture')
# Knit the document, passing in the `params` list, and eval it in a
# child of the global environment (this isolates the code in the document
# from the code in this app).
rmarkdown::render(tempReport, output_file = file,
params = params,
envir = new.env(parent = globalenv())
)
}
)
}
)
In your markdown make sure it's included in the YAML header and call for it with params$somepicture
like the following, sorry I do not know of a function to use in the markdown off the top of my head.
---
title: "Dynamic report"
output: html_document
params:
n: NA
---
```{r}
some_function_to_add_a_picture(params$n)