Hi Petr,

Thank you for your reply.

> Factor <- function(f,n, decreasing=TRUE, ...) {
> ooo<-order(levels(factor(n)), decreasing=decreasing)
> my.order<-levels(factor(f))[ooo]
> factor(f, levels=my.order)
> }

it works incorrectly. Indeed, let's apply with your Factor:

  unames <- c("thousands", "units", "dozens", "hundreds", "thousands",
"dozens")
  u <- c(1000, 1,10,100, 1000, 10)
  Factor(unames, u)

the above produces the following output:

  [1] thousands units     dozens    hundreds  thousands dozens   
  Levels: units thousands hundreds dozens

where "dozens" > "hundreds"

---
Valery

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to