[R] order by which the eigenvalues are presented

William Dunlap wdunlap at tibco.com
Wed May 6 00:22:45 CEST 2015

You can sort the eigenvalues in the order you want with
    o <- order(Re(e$values), decreasing = TRUE)
    o <- order(abs(Re(e$values)), decreasing = TRUE)
followed by
where 'e' is the object that eigen returns.

The main argument to order() is what you want to sort by and the subscript
expression e$values[o] does the rearranging.  You can subscript e$vectors
to rearrange them as well.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, May 5, 2015 at 10:49 AM, Luis Borda de Agua <lbagua at gmail.com>

> I’m using R 3.1.3 in OS X 10.10.3 (Yosemite)
> I use the function “eigen” to calculate the eigenvalues of matrix where
> each element is sampled from a given distribution (normal, beta, etc.).
> According to the information provided:
> "values
> a vector containing the p eigenvalues of x, sorted in decreasing order,
> according to Mod(values)"
> However, for my purposes it would be important to “fix” the order by which
> the eigenvalues are presented. To be more specific, I would like to know
> each time I calculated the eigenvalues from a set of sampled matrix
> elements which is the eigenvalue that provides the largest (or the
> smallest) real part.
> Is there an easy way to enforce this? (I could not find an option in
> "eigen".)
> Is there another function in R that calculates the eigenvalues and shows
> their values without sorting them?
> Thank you in advance,
> Luís Borda de Água
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

	[[alternative HTML version deleted]]

More information about the R-help mailing list