Skip to content
Back to formatted view

Raw Message

Message-ID: <4FB7AFE1.4010808@sapo.pt>
Date: 2012-05-19T14:36:17Z
From: Rui Barradas
Subject: weighted averages for two variables

Hello,

Post a data example, it will give us something to work on, and give you 
better answers.

dput( head(allspecies, 20) )

Then copy the output of this and paste it in your post.
As for your problem, considering it's description, and untested (no 
data), maybe


result <- by(allspecies, allspecies$Year, function(x) 
weighted.mean(x$Depth, x$CPUE))


Also, note that I've renamed the result, 'data' is an R function.

Hope this helps,

Rui Barradas