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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to