Dear Daniel,

Try this:

x=read.table(textConnection("cno      rank
1  1342    0.23
2  1342    0.14
3  1342    0.56
4  2568    0.15
5  2568    0.89"),header=TRUE,sep="")

x[cumsum(tapply(x$rank,x$cno,which.max)),]
cno rank
3 1342 0.56
5 2568 0.89


HTH,

Jorge



On Thu, Jul 24, 2008 at 10:00 AM, Daniel Wagner <[EMAIL PROTECTED]>
wrote:

> Dear R users,
>
> I have a dataframe with lot of duplicate cases and I want to delete
> duplicate ones which have low rank and keep that case which has highest
> rank.
> e.g
>
> > df1
>   cno      rank
> 1  1342    0.23
> 2  1342    0.14
> 3  1342    0.56
> 4  2568    0.15
> 5  2568    0.89
>
> so I want to keep 3rd and 5th  cases with highest rank (0.56 & 0.89) and
> delete rest of the duplicate cases.
> Could somebody help me?
>
> Regards
>
> Daniel
> Amsterdam
>
>
>
>
>
>
>
>
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to