[R] Nested for loops

Michael Knudsen micknudsen at gmail.com
Tue Jul 14 08:25:11 CEST 2009


On Tue, Jul 14, 2009 at 8:20 AM, Michael Knudsen<micknudsen at gmail.com> wrote:

> What do you mean? It looks a like a very general solution to me.

Just got an email suggesting using the functions col and row. For example

temp = matrix(c(1:36),nrow=6)
which(col(temp)>row(temp))

This gives the indices (in the matrix viewed as a vector) of the
above-diagonal entries.

-- 
Michael Knudsen
micknudsen at gmail.com
http://lifeofknudsen.blogspot.com/




More information about the R-help mailing list