Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hyperlink an image in R Markdown

Based upon my understanding of markdown syntax, this is how you add a hyperlink to an embedded image, yet this does not seem to work using R Markdown. What am I doing wrong?

[![alt text][local path to saved image]][web link]

like image 301
rhaefer Avatar asked Feb 14 '17 20:02

rhaefer


People also ask

How do you hyperlink in R Markdown?

Hyperlinks are created using the syntax [text](link) , e.g., [RStudio](https://www.rstudio.com) . The syntax for images is similar: just add an exclamation mark, e.g., ![ alt text or image title](path/to/image) .

How do I add a URL to an image in Markdown?

You can add images to Markdown using the [alt text](image_url) syntax.

How do you paste a link in Markdown?

HTML links that you paste in Markdown are now automatically converted into Markdown links. To paste HTML links as plain text, use cmd/ctrl + shift + v instead.

Can you add image to R Markdown?

To insert an image, you can also use an R code chunk. --- title: "R Markdown Tips and Tricks" output: html_document --- You can also insert an image using R code: ```{r} knitr::include_graphics("img/rmarkdown_hex. png") ``` The image looks smaller by default though.


2 Answers

Use this way: ![Alt text](Web link or path)
Examples: ![Image name](img/image.png) or
![Image name](http://www.host.com/image.png)

Combining with the normal syntax for a hyperlink [text](URL), we have:

[![Alt text](Web link or path)](web link to website)

Example:

[![Image name](image.png)](http://www.host.com/link.html)
like image 190
Gabriel Cesar Avatar answered Oct 12 '22 00:10

Gabriel Cesar


The following worked for me knitted to HTML. The code references an image from a local data store "./data/appStore.png" The image links to the app store url "https://itunes.apple.com/us/app/my-toy-box/id1217665205?mt=8". When hovering over the image the user sees, "My Toy Box on App Store". The alt text "MyToyBox" doesn't appear.

[![MyToyBox](./data/appStore.png "My Toy Box on App Store")](https://itunes.apple.com/us/app/my-toy-box/id1217665205?mt=8)

enter image description here

like image 35
Jacksonsox Avatar answered Oct 11 '22 23:10

Jacksonsox