search for: sum_n

Displaying 2 results from an estimated 2 matches for "sum_n".

Did you mean: sum_
2008 May 08
2
speeding up a special product of three arrays
I am struggling with R code optimization, a recurrent topic on this list. I have three arrays, say A, B and C, all having the same number of columns. I need to compute an array D whose generic element is D[i, j, k] <- sum_n A[i, n]*B[j, n]*C[k, n] Cycling over the three indices and subsetting the columns won't do. Is there any way to implement this efficiently in R or should I resign to do this in C? Thanks, Giuseppe [[alternative HTML version deleted]]
2010 Jun 13
0
Weighted Average application on Summary Dataset
....0098 102 SR3 896.5294118 85 B SR2 914.3636364 55 SR4 957.1966292 178 (Weighted Average of A for N weights) # FUNCTION TO CALCULATE THE WEIGHTED AVERAGE FOR A WEIGHTED BY N WA<-function(A,N) { sp_A<-c(A %*% N) sum_N<-sum(N) WA<-sp_A/sum_N return(WA) } Thanks in advance! Raoul -- View this message in context: http://r.789695.n4.nabble.com/Weighted-Average-application-on-Summary-Dataset-tp2253239p2253239.html Sent from the R help mailing list archive at Nabble.com.