So, mimicking the approach (and the code) of the fortunes package (thanks Achim Zeileis!), I created a simple package (names RXKCD) which allows the user to displays his favorite XKCD strip by selecting the specific number, randomly or simply displaying the current strip.
You can install the package using:
if (!require('RJSONIO')) install.packages('RJSONIO', repos = 'http://cran.r-project.org') if (!require('png')) install.packages('png', repos = 'http://cran.r-project.org') if (!require('ReadImages')) install.packages('ReadImages', repos = 'http://cran.r-project.org') install.packages("RXKCD", repos="http://R-Forge.R-project.org")And you can use it by typing:
library(RXKCD) searchXKCD("someone is wrong") getXKCD(386)Below the result (xkcd license):
Update: The updated version of the package , which is available from CRAN (just type install.packages("RXKCD") ), allows the user to save the xkcd metadata database in a local directory (.Rconfig) and update it in order to have access to the latest XKCD info: see ?saveConfig and ?updateConfig.