Object not found error with ddply inside a function

Today’s solution to this question is to make summarize into here(summarize). e.g.

myFunction <- function(x, y){
    NewColName = "a"
    z = ddply(x, y, here(summarize),
            Ave = mean(eval(parse(text=NewColName)), na.rm=TRUE)
    )
    return(z)
}

here(f), added to plyr in Dec 2012, captures the current context.

Leave a Comment