"diag" has 4 letters
"cbind" has 5 letters :)
--
View this message in context:
http://r.789695.n4.nabble.com/minor-diagonal-in-R-tp2529676p2529746.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing
On Tue, Sep 7, 2010 at 9:09 AM, Trafim Vanishek wrote:
> Dear all,
>
> seems that easy question but cannot find the function for that.
> How to get the elements of the minor diagonal of the matrix?
>
Here are a few possibilities:
# test matrix
x <- matrix(1:16, 4)
# 1
diag(x[, nrow(x):1])
# 2
On Tue, 7 Sep 2010 06:26:09 -0700 (PDT)
"Peng, C" wrote:
>
> This this what you want?
>
> > A=matrix(1:16,ncol=4)
> > A
> [,1] [,2] [,3] [,4]
> [1,]159 13
> [2,]26 10 14
> [3,]37 11 15
> [4,]48 12 16
> > diag(A[1:4,4:1])
> [1] 13 10 7 4
This this what you want?
> A=matrix(1:16,ncol=4)
> A
[,1] [,2] [,3] [,4]
[1,]159 13
[2,]26 10 14
[3,]37 11 15
[4,]48 12 16
> diag(A[1:4,4:1])
[1] 13 10 7 4
>
--
View this message in context:
http://r.789695.n4.nabble.com/minor-diagonal-
Dear all,
seems that easy question but cannot find the function for that.
How to get the elements of the minor diagonal of the matrix?
Thanks a lot.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch
5 matches
Mail list logo