Insert hyperlink to code generated value in R Markdown

Viewed 83

I am trying to create a hyperlink in R Markdown that is linked to an address generated by an R code in the chunk above. But this is not working. Example:

---
title: "R Notebook"
output:
  html_document:
    df_print: paged
---

 
```{r}
x="www.google.com"
```
this is `r x`

[site](`r x`)

output: this is r x generates the true value which is www.google.com

but the link to the word site includes the path to folder where the .rmd file is located followed by www.google.com

any thoughts on what I can do different?

1 Answers

Unfortunately I'm not sure why it works this way, but you need http:// before (or https:// if it's a secure site).

```{r}
x = "http://www.google.com"
```

Then your method should work or you can use the standard html href

[site](`r x`)

<a href=`r x`>site<a>
Related