knitr logo

Upload images Publish images from chunks in the web

The function imgur_upload() in the knitr package enables one to upload images to the image host in R using the RCurl package. If the package option is a function (e.g. imgur_upload) that uploads files to a certain server/host, all plots generated in chunks will be uploaded automatically when the output format is HTML or Markdown.

  • A simple example
  • Two blog posts by Carl Boettiger on how to publish a post to with knitr and RWordPress purely in R, with images uploaded to

This allows you to publish web pages quickly without worrying about image files; you only need to upload a single HTML (to any web servers) or Markdown file (to GitHub, for example).

Brave professors may encourage their brave students to write homeworks with a simple Markdown file, instead of MS Word (which is usually difficult to reproduce and frustrating to format elegantly).

The package option opts_knit$get('') is customizable so that you can use your own function to upload an image. See the script custom_knit.R by Carl for examples.