Thursday, August 2, 2012

Correctly Dispatching on Generic Methods in `*apply()` in R

I've been hacking in R recently for work, and it is a bizarrely amazing
language. I just ran into a situation in which I needed to apply an S3 generic
function to a list (actually, a row-wise iterator on a data.frame)
and hit an annoying rough patch

For those not as well-versed in R (I've been learning it for about two weeks at
this point), "method dispatch" is done in a quirky yet effective way. You define
a generic function, say foo like this: