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. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.