Hello,
Thanks.
The revised 'by' I had posted works with me.
An alternative, more complicated, is using split/sapply.
sapply(split(allspecies, allspecies$Year), function(x)
weighted.mean(x$Depth, x$CPUE))
Rui Barradas
weighted averages for two variables
2 messages · Rui Barradas, mpostje
It works now :) thank you! -- View this message in context: http://r.789695.n4.nabble.com/weighted-averages-for-two-variables-tp4630589p4630610.html Sent from the R help mailing list archive at Nabble.com.