Camarda, Carlo Giovanni wrote:
> Dear R-users,
>
> is there any way to sum up the elements of the "diagonals" of a matrix
> without using a for-loop? While there is a simple way over rows and
> columns, I don't see a straightforward multiplication for the diagonals,
> am I too demanding? Or, more l
Does this do what you want?
> d <- col(mat) - row(mat)
> tapply( mat, d, sum )
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECT
2 matches
Mail list logo