Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show images in Markdown generated from R Markdown on github? #2

Open
jeromyanglim opened this issue Jun 28, 2012 · 0 comments
Open

Comments

@jeromyanglim
Copy link
Owner

I have a few github repositories that have multiple R Markdown files with each R Markdown file in a separate folder.

I want to be able upload these repositories and I want the images to display when someone clicks on a Markdown file.

At the moment, it's accessing the blob version and not the raw version, which is causing issues.

I asked about a general solution to the problem on Stack Overflow.

A general solution is to change the base.url setting

opts_knit$set(base.url='https://github.com/.../raw/.../')

For one particular file I wrote the following:

```{r echo = FALSE}
github_baseurl <- 'https://github.com/jeromyanglim/gelman-bayesian-data-analysis/raw/master/'

filepath <- strsplit(getwd(), '/')[[1]]
# assumes that markdown file is stored in a folder below master
markdown_folder <- filepath[length(filepath)]
image_base_url <- paste0(github_baseurl, markdown_folder, '/')

opts_knit$set(base.url=image_base_url)
```

However, this needs to be done at the very end otherwise preliminary compilations will not display properly on the local computer because the images are not available on github.

Thus, I'm looking for a general solution to this problem.

This also links into my general need to have a single makefile that will convert rmd files to md files in all folders of a repo with github friendly images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant