The problem is simple - How do I insert a variable filename into an rmarkdown PDF? I want to do this:
---
FNL = "image.png"
---
![Some Text](params$FNL)
only I need to pass in the value for FNL when calling rmarkdown::render
The purpose is to give the image a unique ID so that users get images marked for their session.
Anyone able to help with this?
Just use inline R evaluation (works for both HTML and PDF output):
---
title: "Example"
author: "Martin"
date: "March, 11 2017"
output: html_document
params:
img: NULL
---
`r sprintf("![A good boy](%s)", params$img)`
Then you can render the document with the image file by calling
rmarkdown::render("MyDocument.Rmd", params = list(img = "unnamed.png"))
.
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