[R] weighted averages for two variables
mpostje
mayo_jojo at hotmail.com
Sat May 19 14:43:47 CEST 2012
Hi R users,
I have a dataset with multiple variables and i'm trying to weigh average
depths for fish species per year by their abundance (CPUE. I have tried the
weighted.mean function but as i have two columns for the x value the lenghts
differ with the w (CPUE). How do I solve this problem?
So far I have tried this:
data<-by(allspecies, list(allspecies$Depth, allspecies$Year),
function(allspecies)weighted.mean(allspecies$CPUE))
but this doesn't seem to give the proper values, as the CPUE values are
included. I also have many NA's. When i try to exclude those all my values
change.
Thanks for your help!
much appreciated
marjolein
--
View this message in context: http://r.789695.n4.nabble.com/weighted-averages-for-two-variables-tp4630589.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list