Dear Contributors,
I am back asking for help concerning the same type of dataset I was asking
before, in a previous help request.
I needed to sum data over subsample of three time series each of them made
of 100 observations. The solution proposed
were various, among which:
db<-p
dim( db ) <- c(25,4,3)
db2 <- apply(db, c(2,3), sum)
db3 <- t(apply(db2, 1, function(poff) 100-(100*abs(poff/sum(poff)-(1/3))) )
)
My request now is about the function at the end of the calculation in db3.
IF instead of the difference from a number, here 1/3, I need to calculate
the following difference: consider that db3 is a matrix 4x3,
I need to calculate
(db3[1,1] -db3[1,2])+(db3[1,1] -db3[1,3])*0.5 and store it to a cell,
then
(db3[1,2] -db3[1,1])+(db3[1,2] -db3[1,3])*0.5 and store it to a cell,
then
(db3[1,3] -db3[1,2])+(db3[1,3] -db3[1,2])*0.5 and store it to a cell,
then
repeat this for each of the four row of the same matrix. The resulting
matrix should be composed of these distances.
I need to repeat this for each of the subsamples. I realize that there
arecalculations that are repeated but I did not find a strategy that does
not require
Francesca
----------------------------------
Francesca Pancotto, PhD
Università di Modena e Reggio Emilia
Viale A. Allegri, 9
40121 Reggio Emilia
Office: +39 0522 523264
Web: https://sites.google.com/site/francescapancotto/
----------------------------------
[[alternative HTML version deleted]]