Thanks! I think 'ave' was what I was looking for...
On Fri, Sep 26, 2008 at 6:28 PM, jim holtman <[EMAIL PROTECTED]> wrote:
> Try this:
>
>> x
> V1 V2 V3
> 1 a w 200
> 2 a w 100
> 3 b w 500
> 4 b w 200
> 5 b z 300
> 6 b z 400
>> x$rank <- ave(x$V3, x$V1, x$V2, FUN=rank)
>> x
> V1 V
Try this:
> x
V1 V2 V3
1 a w 200
2 a w 100
3 b w 500
4 b w 200
5 b z 300
6 b z 400
> x$rank <- ave(x$V3, x$V1, x$V2, FUN=rank)
> x
V1 V2 V3 rank
1 a w 2002
2 a w 1001
3 b w 5002
4 b w 2001
5 b z 3001
6 b z 4002
>
On Fri, Sep 26, 2008 at 4:54
On Fri, Sep 26, 2008 at 3:54 PM, Matthew Pettis
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'd like to rank obs in a data frame as subset by 2 or more columns...
> The example input would look like the following:
>
> ++++
> x y v
> -- -- --
> a w 200
> a w 100
> b w 500
Try this:
DF
V1 V2 V3
1 a w 200
2 a w 100
3 b w 500
4 b w 200
5 b z 300
6 b z 400
DF$rank <- unlist(lapply(split(DF$V3, list(DF$V1, DF$V2), drop = T), rank))
On Fri, Sep 26, 2008 at 5:54 PM, Matthew Pettis
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'd like to rank obs in a data fram
Hi,
I'd like to rank obs in a data frame as subset by 2 or more columns...
The example input would look like the following:
++++
x y v
-- -- --
a w 200
a w 100
b w 500
b w 200
b z 300
b z 400
++++
And the data frame I want to create i
5 matches
Mail list logo