Thomas Speidel
Thomas Speidel

Reputation: 1443

ddply: pass geometric mean function

I'm fairly new to ddply. I'm trying to apply a geometric mean function to ddply, like so:

monthly.ave <- ddply(monthly,
           c("year", "month"), 
           summarise,
           mean = mean(abs.hrs.prop, na.rm=TRUE),
           median = median(abs.hrs.prop, na.rm=TRUE),
           geom.mean = geometric.mean(abs.hrs.prop, na.rm=TRUE))

ddply, of course, doesn't know geometric.mean. So, how can I pass a geometric mean function to ddply?

Upvotes: 0

Views: 484

Answers (1)

Thierry
Thierry

Reputation: 18487

This will give you a list of potential relevant function to calculate a geometric mean.

library(sos)
findFn("geometric mean")

Upvotes: 2

Related Questions