[R] lower triangle

About this list Date view Thread view Subject view Author view Attachment view

From: Wilkinson, Mark (Mark.Wilkinson@stjude.org)
Date: Sat 21 Dec 2002 - 06:58:48 EST


Message-id: <A1DAD6685C12D511B20F00034725151380CD96@sjmemexc3.stjude.org>

Hi,

I want to compute the lower triangle of a square matrix (optionally, sans
diagonal). With for() loops I can do something like this:

## 5 by 5 matrix rtn
for (j in 1:5) {
        for (k in 1:j) {
                if (j != k) { ## optional
                rtn[j, k] <- my.func(j, k)
                }
}
}

I'd like to do this with apply(). Is there some way I can do this kind of
'short-circuit'?

Thanks,

Mark Wilkinson
Informatics Analyst
St. Jude Children's Research Hospital
Department of Pharmaceutical Sciences

______________________________________________
R-help@stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jun 2004 - 09:31:59 EST