[R] Confused by code?
Bazman76
h_a_patience at hotmail.com
Sun Sep 23 22:52:57 CEST 2012
x<-matrix(c(1,0,0,0,1,0,0,0,1),nrow=3)
> y<-matrix(c(0,0,0,1,0,0,1,1,0),nrow=3)
> z<-matrix(c(0,1,0,0,1,0,1,0,0),nrow=3)
> x[z]<-y[z]
The resultant matrix x is all zeros except for the last two diagonal cells
which are 1's.
While y is lower triangualr 0's with the remaining cells all ones.
I really don't understand how this deceptively simple looking piece of code
is giving that result can someone explain please.
I'm obviously missing something pretty basic so please keep your answer
suitably basic.
--
View this message in context: http://r.789695.n4.nabble.com/Confused-by-code-tp4643946.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list