Re: [R] the results of the SORT function differ from Scilab/Matlab for Complex Numbers

2012-11-08 Thread Duncan Murdoch
On 08/11/2012 4:42 PM, Cleber N.Borges wrote: Ok, thanks. There are a simple mode for emulate this behaviour? This should sort by modulus then argument (phase): x[order(Mod(x), Arg(x))] It does strange things if x happens to be real: > x <- (-5):5 > sort(x) [1] -5 -4 -3 -2 -1 0 1 2 3

Re: [R] the results of the SORT function differ from Scilab/Matlab for Complex Numbers

2012-11-08 Thread Cleber N.Borges
Ok, thanks. There are a simple mode for emulate this behaviour? Cleber Em 08/11/2012 19:25, Thomas Lumley escreveu: > On Fri, Nov 9, 2012 at 10:02 AM, Cleber N.Borges > wrote: > > Hello useRs, > > The results of the SORT function differ from Scilab/Matlab for

Re: [R] the results of the SORT function differ from Scilab/Matlab for Complex Numbers

2012-11-08 Thread Thomas Lumley
On Fri, Nov 9, 2012 at 10:02 AM, Cleber N.Borges wrote: > Hello useRs, > > The results of the SORT function differ from Scilab/Matlab for Complex > Numbers in my example. > This design is the desirable in R? > Well, it's deliberate and documented. R sorts complex numbers by real part then by ima

[R] the results of the SORT function differ from Scilab/Matlab for Complex Numbers

2012-11-08 Thread Cleber N.Borges
Hello useRs, The results of the SORT function differ from Scilab/Matlab for Complex Numbers in my example. This design is the desirable in R? Thanks. Cleber r <- c( 1.7507+0.1689i, 1.7507-0.1689i, 1.3886+0.i, 1.0458+0.0792i, 1.0458-0.0792i, 0.8279+0.1861i, 0.8279-0.1861i, 0.8263+0.3731