Try these functions (modify to suit your needs:

 tri1 <- function(x){
        n <- dim(x)[2]
        for(i in n:1){
                for( j in 1:(n-i+1) ){
                        cat(sprintf('  %5.2f',x[j,j+i-1]))
                }
                cat("\n")
        }
}


tri2 <- function(x){
        n <- dim(x)[2]
        for(i in n:1){
                cat( rep(' ', 3*(i-1)), sep='',collapse='' )
                for( j in 1:(n-i+1) ){
                        cat(sprintf(' %5.2f',x[j,j+i-1]))
                }
                cat("\n")
        }
}

tmp <- matrix(1:25,5) # not symmetric, but you get the idea
tri1(tmp)
tri2(tmp)

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Cal Stats
Sent: Monday, June 19, 2006 11:11 AM
To: r help
Subject: [R] Plotting Upper triangle of Matrix with diagonal as the Base

Hi..
  
     I a have a symmetric matrix to plot . I would like to plot  only
the Upper triangle but with the diagonal as the Base of the  rectangle.
Is there an easy way to do it.
  
  Thanks.
  
  Harsh
  
                        
---------------------------------

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to