Message-ID: <1077586229.16414.79.camel@localhost.localdomain>
Date: 2004-02-24T01:30:30Z
From: Marc Schwartz
Subject: quesion on diag of matrix
In-Reply-To: <20040224005325.29578.qmail@web11509.mail.yahoo.com>
On Mon, 2004-02-23 at 18:53, li xian wrote:
> How to get the sum of the diag of matrix?
> Thanks!
If 'm' is your matrix:
sum(diag(m))
See ?sum and ?diag, the latter of which will extract the diagonal of the
matrix.
Be sure to read the help for diag() fully for some of the usage caveats.
HTH,
Marc Schwartz