Created
July 26, 2012 20:35
-
-
Save rmflight/3184342 to your computer and use it in GitHub Desktop.
Rmd programmatic links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r showLink, results='asis'} | |
var1 <- "672" | |
var2 <- "12189" | |
srchVar <- paste(var1, var2, collapse=",", sep=",") | |
tmp1 <- paste('<a href="http://www.ncbi.nlm.nih.gov/gene?term=', srchVar, '">Results</a>', sep="") | |
cat(tmp1) | |
``` |
You can make it more compact and readable:
```{r}
var1 <- "672"
var2 <- "12189"
```
[Results](http://www.ncbi.nlm.nih.gov/gene?term=`r I(c(var1, var2))`)
It is simple just because the coincidence that the knitr inline
hook function uses paste(..., collapse = ', ')
which happens to be valid for the URL for your case.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Want to have R create a link programmatically so that those viewing the final report can simply click on it and be taken to the correct page? then this is what you need.