Skip to content
Prev 179473 / 398513 Next

tapply changing order of factor levels?

Jim's advice is patently false. Please read ?tapply for correct details.

Counterexample:
[1] a b c a b c
Levels: c b a
c          b          a 
 0.4545897 -1.0544782  0.4682773   

Bert Gunter
Genentech Nonclinical Statistics


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of jim holtman
Sent: Wednesday, May 06, 2009 6:57 AM
To: Chirantan Kundu
Cc: r-help at r-project.org
Subject: Re: [R] tapply changing order of factor levels?

The result of 'tapply' is just a named vector and the names are in
alphabetical order.  If you want them printed in a different order, then you
have to specify it.  Since you have the order in 'mylevels', this will work:
int [1:3(1d)] 4 3 2
 - attr(*, "dimnames")=List of 1
  ..$ : chr [1:3] "IN0019800021" "IN0020020064" "IN0020020155"
IN0020020155 IN0019800021 IN0020020064
           2            4            3

        
On Wed, May 6, 2009 at 9:45 AM, Chirantan Kundu <chirantan at 2pirad.com>wrote:

            
mydata<-c("IN0020020155","IN0019800021","IN0020020064","IN0020020155","IN001
9800021","IN0019800021","IN0020020064","IN0020020064","IN0019800021")
http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting
-guide.html>