Hello list,
my question is related to svd of a matrix:
b=matrix(rnorm(50),10,5) mysvd=svd(b)
I would like to compute each xi where xi = di* ui %*% t(vi). I do it by :
xlist=sapply(1:ncol(b), function(x1,y) y$d[x1]*y$u[,x1]%*%t(y$v[,x1]),y=mysvd,simplify=F) # result is a list
xarray=array(sapply(1:ncol(b), function(x1,y) y$d[x1]*y$u[,x1]%*%t(y$v[,x1]),y=mysvd),c(nrow(b),ncol(b),ncol(b))) # result is an array
Now i would like to compute cumulative sum:
y1=x1 # y[,,1] y2=x1+x2 # y[,,2] ...
I have try to do it with apply without succes:
y=apply(xarray,c(1,2),cumsum)
The results are good but not in the format that I want. I could modify the results to modify the format but I am sure that it exists another faster way.
Is it possible to do the same on the list ?
Thanks in advance
Sincerely
St�phane DRAY
--------------------------------------------------------------------------------------------------
D�partement des Sciences Biologiques Universit� de Montr�al, C.P. 6128, succursale centre-ville Montr�al, Qu�bec H3C 3J7, Canada
Tel : (514) 343-6111 poste 1233 Fax : (514) 343-2293
E-mail : [EMAIL PROTECTED]
--------------------------------------------------------------------------------------------------
Web http://www.steph280.freesurf.fr/
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
