ozanj / rclass

4 stars 3 forks source link

how to insert URL to image #7

Open ozanj opened 5 years ago

ozanj commented 5 years ago

general Markdown syntax for inserting an image in text of .Rmd file is:

This works if image is saved in that directory on the user's computer. Downside of this approach is that students have to save images and store them in a specific directory.

I would rather save images to our github website and include path to that URL. however, have not been able to get this to work.

can you figure out how?

@cyouh95

cyouh95 commented 5 years ago

According to here, it looks like LaTeX has no way of displaying files hosted on web. But one workaround is to include this at the top of the .Rmd file to first download all the images needed:

```{r echo=FALSE}
if(!file.exists('transform-logical.png')){
    download.file(url = 'https://raw.githubusercontent.com/ozanj/rclass/master/lectures/lecture2/transform-logical.png',
                  destfile = 'transform-logical.png',
                  mode = 'wb')
}

Then those should exist when it is used later in the file:
```r
![](transform-logical.png)