A bit of fun with R

July 22, 2011
By

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

R isn't just about serious things like model inference and prediction intervals and big analytics. Sometimes, R lets its hair down and just does weird and wonderful things because ... well just because. For example, with a package from Paulo Sonego, it can display your favourite XKCD cartoon:

> install.packages("RXKCD", repos="http://R-Forge.R-project.org",type="source")
> searchXKCD("support")
   num                    title
1    8              Red spiders
2  278        Black Hat Support
3  384       The Drake Equation
4  480                    Spore
5  554          Not Enough Work
6  619       Supported Features
7  644                  Surgery
8  745                Dyslexics
9  806             Tech Support
10 818                  Illness
11 838                 Incident
12 627 Tech Support Cheat Sheet
> getXKCD(806)

Tech_support

(Hmm, maybe that's not so frivolous after all. The searchXKCD function was perfect for finding one of my favourite XKCD comics, and the source code for getXKCD is a great example of doing JSON queries from R and also of using raster images.)

Here's another example of a bit of fun with R. Neil Gunther of Performance Dynamics shows us how to create a winking pink elephant with R:

Winking elephant

(Hmm, maybe that isn't so frivolous after all. The code that generates that image is actually a really good example of doing complex arithmetic in R -- the elephant is based on a Fourier transform generated by just 5 parameters -- and also provides a good example of using the animation package to create animated GIFs in R.)

What other fun things do you use R for? Let us know in the comments.

To leave a comment for the author, please follow the link and comment on his blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags:

Comments are closed.