ZZY ZYBOYS
2010-Jun-17 04:44 UTC
[R] How to take the lower triangular part from a full matrix
Dear all: I have a question regarding on how to take the lower triangular part from a full matrix. for example 1 2 3 1 0 0 3 4 5 to 3 4 0 7 8 9 7 8 9 Thanks, Joey [[alternative HTML version deleted]]
Romain Francois
2010-Jun-17 06:43 UTC
[R] How to take the lower triangular part from a full matrix
Le 17/06/10 06:44, ZZY ZYBOYS a ?crit :> > Dear all: > > I have a question regarding on how to take the lower triangular part from a > full matrix. > for example > 1 2 3 1 0 0 > 3 4 5 to 3 4 0 > 7 8 9 7 8 9 > > Thanks, > JoeyPlease take at least the time to send a reproducible example on how you make you data, i.e: > x <- matrix( 1:9, nr = 3, byrow = T ) See ?lower.tri > x[ upper.tri(x) ] <- 0 Or see ?row and ?col > x[ row(x) < col(x) ] <- 0 Also note that ??triangular finds lower.tri Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/98Uf7u : Rcpp 0.8.1 |- http://bit.ly/c6YnCi : graph gallery collage `- http://bit.ly/bZ7ltC : inline 0.3.5