Things I considered:

However, for various reasons I don't want to do this (I have trouble uploading when behind a firewall; it's slow; it creates an unnecessary dependency)

Rpubs: There's also RPubs which is quite cool. However, at time of posting it seems more suited to single markdown documents rather than multiple R markdown documents. And it doesn't provide such a close link between source R Markdown and the Markdown document.

Question

Is there a workflow for using R Markdown and knitr to produce Markdown files which when uploaded to github permit the Markdown file to display images stored in the github repository?

there's some option to embed images in html using some base64 encoding magic, I can't remember where I saw this though
–
baptisteJun 28 '12 at 4:07

@baptiste does this work for markdown? I had the impression that this only works for HTML but I haven't looked that closely.
–
Jeromy AnglimJun 28 '12 at 4:09

Optionally you might run a regexp on each generated document which would change the foo/blob/... to foo/raw/... in the markdown files.
–
daroczigJun 28 '12 at 7:08

1

I can base64 encode images in markdown if you want; just file an issue to me: github.com/yihui/knitr/issues Markdown is not different with HTML here; it is just a matter of ![](url) or <img src='url'>
–
YihuiJun 28 '12 at 15:11

2

@JeromyAnglim I have almost finished the work, but unfortunately I just realized github does not support base64 encoded images in their markdown... sigh. Just contacted them.
–
YihuiJul 7 '12 at 20:04

+1 thanks. I'm currently exploring how this would actually work in an elegant way particularly where you have multiple R markdown files in multiple folders. There's also the challenge of incorporating it into something like a makefile so that it is only added at the very end, just prior to pushing to github. Naturally if you add it before you've committed the image to github, then you can't see the image in your preliminary data analyses.
–
Jeromy AnglimJun 28 '12 at 4:07

All you would have to do is run knit with base.url = '' until you wanted to push to github, then use the github url for the final run.
–
mnelJun 28 '12 at 4:22

1

and then when you want to update the code, return it back to base.url='', and then when you update it change it back to the github base.url, and make sure that you type everything perfectly for every R Markdown file in every subfolder. I agree it's not that difficult, but I still think there is a small task in making it elegant and automated, especially when you have a repository with many R Markdown files. For example, I have one repo with 20+ separate R Markdown folders. But I guess I'm starting to drift into a slightly different question to what I originally asked.
–
Jeromy AnglimJun 28 '12 at 4:29

1

I've edited the answer to (perhaps) help with this problem.
–
mnelJun 29 '12 at 4:44

1

Probably you need to set base_url to its previous value after call to knit.github?
–
mpiktasJul 2 '12 at 8:08

It is possible to tweak it so that gitrep and gitbranch will be reported by git. Here I assumed that I am one directory level below the main git repository directory. Again this might be tweaked to accommodate more complicated scenarios.

I've tested on github, here is the Rmd file and corresponding md file.