Automating my R workflow

Cog and wheels of a wooden clock
David Hoffman 2012

In his book, R Packages, Hadley Wickham, a professor of statistics and foremost developer in the R community, wrote: “anything that can be automated, should be automated”. Though made in reference to package development in particular, this statement applies pretty much to other aspects of computing.

When I started my journey in R a few years ago, I was taught how to skip through an R script using CTRL+ENTER (for RStudio IDE) and CTRL+R (RGui.exe in Windows) and examine the output in the R console. I really enjoyed being able to see my results as the code was executed line by line. But after a while, it gets a bit boring.

After some time, I learnt how to use the rmarkdown package and discovered that by clicking on a little green button, I could run chunks of the R code embedded in the document when opened within the RStudio IDE. This was infinitely more visually appealing than stepping through an R script. Better still, I could write a narrative on the code in the plain text portions of the .Rmd document. Sweet.

I started using this approach heavily in my personal practice time and also when I was doing something instructional. I soon graduated to working with the presentation format, too.

Then a few months ago a big shift occurred in my R workflow as I came to learn about batch scripting. Although, I had experience invoking R from the command line, it hadn’t really dawned on me that I should set up my scripts to run automatically and yield some kind of output. Enter Rscript.

(To be continued…)









Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s