'Rmarkdown hyperlink created from a chunk
I would like to create a hyperlink in an RMarkdown document that changes according to the value of a variable located in a chunk. for example
variable <- "questions/ask"
http_address <- glue::glue("https://stackoverflow.com/{variable}")
[Click to reveal](`r http_address)
In the html document I would like to hover over "Click to reveal" so that the link is https://stackoverflow.com/questions/ask. However the above code doesn't work. Any tips would be appreciated
Solution 1:[1]
Using chunk option results="asis" and cat you could do
---
title: "Untitled"
output: html_document
date: '2022-04-19'
---
```{r results='asis', echo = FALSE}
variable <- "questions/ask"
http_address <- glue::glue("https://stackoverflow.com/{variable}")
cat("[Click to reveal](", http_address, ")")
```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

