[R] Help for R (Advanced matrix addition (large or undefined number of matrices)
Ben Bolker
bolker at ufl.edu
Wed Aug 12 13:55:30 CEST 2009
Rusyte, Lina wrote:
>
> Dear Sirs,
>
> I would like to ask you, what function can I use for matrices addition?
> I couldn't find any information about it in the manual or in the
> internet.
> (A+B suits, when the number of matrixes is small, function sum() doesn't
> suit for matrices addition, because it sums all variables in the
> matrices and produces as an answer single number, not a matrix).
> I would be very thankful for your help.
>
>
If you can get your matrices into a list, use Reduce():
> A = matrix(runif(100),nrow=10)
> B = Reduce("+",list(A,A,A,A,A))
> max(abs(B-5*A))
--
View this message in context: http://www.nabble.com/Help-for-R-%28Advanced-matrix-addition-%28large-or-undefined-number-of-matrices%29-tp24934303p24934911.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list