Re: [Rd] vector labels are not permuted properly in a call to sort() (R 2.1)

2005-10-05 Thread Prof Brian Ripley
The main problem is that R is inconsistent here. There are lots of branches through the sort() code. Greg showed one. Here are four more > sort(y, method="quick") [,1] [,2] A15 B26 C37 D48 > names(y) <- letters[1:8] > sort(y) h g f e d c b a 1 2 3 4 5 6 7 8 >

Re: [Rd] vector labels are not permuted properly in a call to sort() (R 2.1)

2005-10-05 Thread David James
Martin Maechler wrote: > > "AndyL" == Liaw, Andy <[EMAIL PROTECTED]> > > on Tue, 4 Oct 2005 13:51:11 -0400 writes: > > AndyL> The `problem' is that sort() does not doing anything special when > given > AndyL> a matrix: it only treat it as a vector. After sorting, it copies >

Re: [Rd] vector labels are not permuted properly in a call to sort() (R 2.1)

2005-10-05 Thread Martin Maechler
> "AndyL" == Liaw, Andy <[EMAIL PROTECTED]> > on Tue, 4 Oct 2005 13:51:11 -0400 writes: AndyL> The `problem' is that sort() does not doing anything special when given AndyL> a matrix: it only treat it as a vector. After sorting, it copies AndyL> attributes of the original

Re: [Rd] vector labels are not permuted properly in a call to sort() (R 2.1)

2005-10-04 Thread Liaw, Andy
The `problem' is that sort() does not doing anything special when given a matrix: it only treat it as a vector. After sorting, it copies attributes of the original input to the output. Since dimnames are attributes, they get copied as is. Try: > y <- matrix(8:1, 4, 2, dimnames=list(LETTERS[1:4]

[Rd] vector labels are not permuted properly in a call to sort() (R 2.1)

2005-10-04 Thread Greg Finak
Not sure if this is the correct forum for this, but I've found what I would consider to be a potentially serious bug to the unsuspecting user. Given a numeric vector V with class labels in R, the following calls 1. > sort(as.matrix(V)) and 2. >as.matrix(sort(V)) produce different ouput. Th