so what do i use r for?
an overview and some examples
Yesterday at the WIDS conference, I found myself trying to explain why I was there, and the first response I came up with was that I’ve been using R for about 13 years — not really an explanation, so of course someone followed-up by asking me what exactly is it I do with R (I’m a physicist). Here’s what I could have answered. A more complete version of my interactions with R is in this other blog post.
scripting
Familiarity with the language is the main reason I use R for all kinds of scripting and batch-processing jobs. Any language would do, and I’ve used many — bash, ruby, python, gnuplot, … — but R is quite versatile and can easily be used as a wrapper for other tools, such as pandoc
, latex
, etc. In combination with Rstudio’s support for R markdown, the fine customisation allowed by yaml
proves to be a very powerful and efficient workflow to automate all kinds of tasks, which may not seem related to R at all. I’ll mention,
- the automation of the posters, which relies heavily on yaml, markdown, pandoc, lua, and latex; Rstudio makes it a one-click process.
- the automation of Gandalf’s resume with a custom template
- the automated creation of my photography albums and portfolio
I also use R markdown for lecture slides, assignments, general correspondence, seminar announcements, etc.
hobbies
There’s certainly a fun aspect in playing with some packages such as my experiments with rayshader, this blog, answering too many SO questions and developing obscure hacks in grid graphics.
presentations
Although I do not tend to use R for my presentations (aside from lecture slides), I’ve given a number of presentations and turorials about graphics, heavily inspired by the concepts from ggplot2 and R graphics in general (as well as wisdom from the community).
exploratory data analysis
OK, I guess we’re slowly heading towards the more obvious — yes, I do use R in my research also. I’ve analysed hundreds of thousands of spectra, images, fitted models, I’ve made plots (lots and lots of them), etc. More recently I’ve started making use of shiny to create interactive apps that complement research papers or help non-programmers explore numerical simulations.
graphics
R is not an obvious choice for a physicist, and it certainly was even less obvious 13 years ago, but its first-class graphics were the first thing that appealed to me (as a Matlab user). I’ve become quite involved in the grid graphics system, with numerous packages developed over the years, most of them around ggplot2.
numerical simulations
The major sticking point in comparison to Matlab for a physicist is that numerical simulations in R are painfully slow. In fact, I often have two or three versions of the same code, one in R, one in Rcpp, and one in Matlab (Matlab wins, because of its use of Intel’s MKL). That being said, I’ve been an early adopter and happy user of Rcpp and RcppArmadillo, and most of my numerical simulations use them.