It looks like you might be asking for this. This gets the "lower right" diagonal.
> mat <- matrix(c(1,4,3,4,1,2,3,2,1), nrow = 3, ncol=3, byrow=TRUE) > mat [,1] [,2] [,3] [1,] 1 4 3 [2,] 4 1 2 [3,] 3 2 1 > diag(mat[rev(2:nrow(mat)),-1]) [1] 2 2 > This gets the upper off-diagonal > diag(mat[,-1]) [1] 4 2 Rich You can accomplish much with subscripting. Rich On Thu, Jan 20, 2011 at 4:20 PM, Joe P King <j...@joepking.com> wrote: > So many matrices are square symmetrical (i.e. variance-covariance > matrices), > is there any way to get R to split the matrix on its diagonal and just > return one diagonal? > > > > So if I have > > > > mat<-matrix(c(1,4,3,4,1,2,3,2,1), nrow = 3, ncol=3, byrow=TRUE) > > > > is there anyway to get the lower right diagonal instead of the entire > symmetric matrix? > > > > ------------------------------------------- > > Joe King, M.A. > > Ph.D. Student > > University of Washington - Seattle > > 206-913-2912 > > <mailto:j...@joepking.com> j...@joepking.com > > ------------------------------------------- > > Ad astra per aspera - "Through hardships to the stars" > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ 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.