Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (25 sloc) 1.33 KB
This is an example of using **knitr** with extended markdown (e.g. [GFM]( and uploading images to automatically. Note you should set the graphical device to create images that can be displayed in the web browser, e.g. `dev = 'png'` (it is the default for markdown output) works but `'pdf'` does not.
First, the input file was named as `knitr-upload.Rmd` ([source](, and **knitr** will automatically determine the output filename to be ``.
I used the code below to make sure **knitr** will upload images and set some global chunk options.
```{r setup}
opts_knit$set( = imgur_upload, base.url = NULL) # upload all images to
opts_chunk$set(fig.width=5, fig.height=5, cache=TRUE)
Now we write some code chunks in this markdown file:
## a simple calculator
## boring random numbers
We can also produce plots which are uploaded to
```{r md-cars, message=FALSE}
par(mar = c(4, 4, .1, .1))
plot(mpg~hp, data=mtcars, pch=19)
par(mar = c(3, 2, .1, .1))
matplot(t(scale(mtcars)), lty=1, type='l', xaxt='n', ylab='')
axis(1, seq(ncol(mtcars)), colnames(mtcars))
So **knitr** is ready with GitHub with a single markdown file.
You can’t perform that action at this time.