Nicholas Tierney Original witty remark

Simple Guide to S3 Methods

So I’ve just submitted my first article to the R Journal!

Woohooo!

The paper, “A Simple Guide to S3 Methods”, is my attempt at a quick and simple guide to using S3 methods in R. Although not my first publication, it is my first solo publication, which is exciting.

You can read the pre-print on arxiv here.

Why write it?

Because I think S3 methods are underused. They are elegant, simple, and really useful. Hadley Wickham describes them nicely in Advanced R.

S3 is informal and ad hoc, but it has a certain elegance in its minimalism: you can’t take away any part of it and still have a useful [Object Oriented] system.

How it started

Last year I ripped some functions from a monster if-then-else statement, and created individual S3 methods. I kept some notes as I did this, which eventually turned into a draft blog post. However, a colleague suggested I turn the blog post into a publication for the R Journal. Why not?

The process

I got it about 95% of the way relatively quickly thanks to fine folks like Miles McBain providing valuable feedback, and to the R package rticles which provides a pre-built R Journal template.

However, I ran into some issues around special characters in rticles, which halted my progress. It looked unappealing to fix in LaTeX, so it sat on the backburner.

Until…?

I started updating my CV last week. I was reminded that I still had not submitted the S3 methods paper. I had a brainwave that I could get around my problem by silently running the code chunk and then copying and pasting the code output manually in markdown. This worked rather marvelously. You can see the RMarkdown chunk here on github.

Further thoughts on the paper.

The paper might miss out on some of the finer features of S3 methods, but its main goal was to get people using S3 methods by providing motivation for why they might want to use them, and why they should use them as opposed to writing something like a series of if-then-else loops.

I’m excited to see feedback from the R Journal, hopefully I didn’t miss something terribly important about S3 methods.