Displaying 1 result from an estimated 1 matches for "sum_c".
Did you mean:
sum_
2010 Jun 26
7
Calculating Summaries for each level of a Categorical variable
...aset: RT=
R A T W H
R1 10 20 20 10
R2 60 20 50 10
R3 45 10 20 50
R4 68 50 20 10
R1 73 20 40 46
R3 25 30 10 54
R3 36 90 20 10
R2 29 10 30 30
# FUNCTION TO CALCULATE THE WEIGHTED AVERAGE FOR A WEIGHTED BY C
WA<-function(A,C) {
sp_A<-c(A %*% C)
sum_C<-sum(C)
WA<-sp_A/sum_C
return(WA)
}
I am trying to incorporate the additional step of calculating the weighted
average of A,T,W and H for each level of R. Need help with this.
Thanks in advance!
Raoul
--
View this message in context: http://r.789695.n4.n...