Error in code from split-apply-combine paper - how to resolve?

plyr, r

Solution

It should be

models <- alply(ozone, 1:2, deseasf)
deseas <- ldply(models, resid)

Problem

To try and get to grips with data manipulations in R, I've started reading Hadley's paper on split-apply-combine. I'm on page 3 and trying to go through the code to understand it. Unfortunately the code is erroring and my reproduction is faithful (I've done c&p and handtyped). As I'm trying to learn this stuff and I'm right at the beginning I can't actually tell what's wrong with it. I tried it on both R2.5 and R3.0 ``` library("MASS") library("plyr") data(ozone) one<-ozone[1,1,] month<-ordered(rep(1:12,length=72)) model<-rlm(one ~ month - 1) deseas<-resid(model) deseasf<-function(value) {rlm(value ~ month - 1)} models<-aaply(ozone,1:2,deseasf) deseas<-aaply(models,1:2,resid) ``` Where the models line errors with `Error: Results must have one or more dimensions.` Can somebody tell me whether it works for them, or what needs to be fixed/amended if it doesn't and why? PS - Can't check on http://plyr.had.co.nz/ for errata because my work proxy currently blocks the site!

Original source