I’m trying to make a function using ddply inside of it. However I can’t get to work. This is a dummy example reproducing what I get. Does this have anything to do this bug?
library(ggplot2)
data(diamonds)
foo <- function(data, fac1, fac2, bar) {
res <- ddply(data, .(fac1, fac2), mean(bar))
res
}
foo(diamonds, "color", "cut", "price")
I don’t believe this is a bug.
ddplyexpects the name of a function, which you haven’t really supplied withmean(bar). You need to write a complete function that calculates the mean you’d like:Also, you shouldn’t pass strings to
.(), so I changed that toc(), so that you can pass the function arguments directly toddply.