Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-29 Thread Sebastian Bauer
Hi! On 08/24/2011 07:46 PM, David Winsemius wrote: I was looking for an elegant solution ;) In the real case I have double values and this would be quite inefficient then. Still no r-code: Then what about rank(order(...) , further-ties.method-argument) ? I think that, as order() always

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-29 Thread peter dalgaard
On Aug 29, 2011, at 15:39 , Sebastian Bauer wrote: rr - data.frame(a = c(1,1,1,1,2), b=c(1,2,2,3,1)) ave(order(rr$a, rr$b), rr$a, rr$b ) [1] 1.0 2.5 2.5 4.0 5.0 Actually, this may be a solution I was looking for! Note that it assumes that rr to be sorted already (hence the first

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-25 Thread Sebastian Bauer
Hi! On 08/24/2011 07:46 PM, David Winsemius wrote: I was looking for an elegant solution ;) In the real case I have double values and this would be quite inefficient then. Still no r-code: Then what about rank(order(...) , further-ties.method-argument) ? I think that, as order() always

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-25 Thread David Winsemius
On Aug 25, 2011, at 7:56 AM, Sebastian Bauer wrote: Hi! On 08/24/2011 07:46 PM, David Winsemius wrote: I was looking for an elegant solution ;) In the real case I have double values and this would be quite inefficient then. Still no r-code: Then what about rank(order(...) ,

[R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread Sebastian Bauer
Hello, I'd like to rank rows of a data frame similar to what rank() does for vectors. However, ties should be broken by columns that I specify. If it is not possible to break a ties (because the row data is essentially the same), I'd like to have the same flexibility that rank() offers. Is

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread David Winsemius
On Aug 24, 2011, at 11:09 AM, Sebastian Bauer wrote: Hello, I'd like to rank rows of a data frame similar to what rank() does for vectors. However, ties should be broken by columns that I specify. If it is not possible to break a ties (because the row data is essentially the same), I'd

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread Sebastian Bauer
Hi! I'd like to rank rows of a data frame similar to what rank() does for vectors. However, ties should be broken by columns that I specify. If it is not possible to break a ties (because the row data is essentially the same), I'd like to have the same flexibility that rank() offers. Is

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread David Winsemius
On Aug 24, 2011, at 1:11 PM, Sebastian Bauer wrote: Hi! I'd like to rank rows of a data frame similar to what rank() does for vectors. However, ties should be broken by columns that I specify. If it is not possible to break a ties (because the row data is essentially the same), I'd like to

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread Sebastian Bauer
Hi! in R? Basically, what I need is a mixture of order() and rank(). While the former allows to specify multiple vectors, it doesn't provide the flexibility of rank() such that I can specify what happens if ties can not be broken. An example of this simple problem would clarify this greatly.

Re: [R] Function rank() for data frames (or multiple vectors)?

2011-08-24 Thread David Winsemius
On Aug 24, 2011, at 1:37 PM, Sebastian Bauer wrote: Hi! in R? Basically, what I need is a mixture of order() and rank(). While the former allows to specify multiple vectors, it doesn't provide the flexibility of rank() such that I can specify what happens if ties can not be broken. An