> x <- 1:5
> diag(x)[rev(seq(length(x))),]


On Tue, Jan 11, 2011 at 12:56 PM, Ron Michael <ron_michael70@yahoo.com>wrote:

> Hi, is there any direct R function to write an diagonal matrix in an
> opposite way? for example I want to get like:
>
> > diag(rnorm(5))[,5:1]
>            [,1]       [,2]       [,3]      [,4]       [,5]
> [1,]  0.0000000  0.0000000  0.0000000  0.000000 -0.1504687
> [2,]  0.0000000  0.0000000  0.0000000 -2.139669  0.0000000
> [3,]  0.0000000  0.0000000 -0.2102133  0.000000  0.0000000
> [4,]  0.0000000 -0.2609686  0.0000000  0.000000  0.0000000
> [5,] -0.6818889  0.0000000  0.0000000  0.000000  0.0000000
>
> Is there any typical name for this type of matrix?
>
> Thanks,
>
>
>        [[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]]

