Re: [R] summary(as.factor(x) - force to not sort the result according factor levels

From: Tony Plate <tplate_at_acm.org>
Date: Tue 03 May 2005 - 07:38:17 EST

Christoph Lehmann wrote:
> Hi
> The result of a summary(as.factor(x)) (see example below) call is sorted
> according to the factor level. How can I get the result not sorted but
> in the original order of the levels in x?

by creating the factor with the levels in the order you want:

 > test <- c(120402, 120402, 120402, 1323, 1323,200393, 200393, 200393, 200393, 200393)
 > summary(factor(test, levels=unique(test))) 120402 1323 200393

      3 2 5



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 03 07:46:40 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:32 EST