[R] Ranking factors given a weight

Albert Vilella avilella at gmail.com
Mon Dec 19 11:03:17 CET 2005


Hi all,

I'm trying to rank a couple of factors by a variable and a weight of
the variable in each occurrence (some samples are bigger than others).

input = data.frame(
  alfa = rnorm(5000),
  weight = rnorm(5000,-50000,100000),
  tag1 = sample(c("a","b","c","d"),5000,replace=TRUE),
  tag2 = sample(c("i","j","k"),5000,replace=TRUE)
  )

alfa are the observations, each of which has a weight, and tag1 and
tag2 are the factors.

The idea would be to have a ranking of tag1, tag2, and a combination
of both.

There must be a way to do that with ave() or sort() but I haven't
found how.

Thanks in advance,

    Albert.




More information about the R-help mailing list