Skip to content

Creating Identity Matrices

1 message · E. D. Isaia

#
Dear Alan, here's how to define a simple nxn Identity matrix:

n<-c(5)
 I <- matrix(0,nrow=n,ncol=n)
I[row(I)==col(I)] <- 1

E.D.Isaia
"Alan T. Arnholt" wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._