[R] extracting max row from data matrix
Adam D. I. Kramer
adik-rhelp at ilovebacon.org
Tue Sep 9 00:41:20 CEST 2008
Hi Srini,
This may be as simple as tapply(weight,fruit,max)
or t(that) if you want it as you specified.
--Adam
On Sun, 7 Sep 2008, Srinivas Iyyer wrote:
> dear group,
> i have a data matrix with some replicate items with different values. I want to extract the row with max value.
>
> for example:
>> x
> fruit weight
> 1 apple 1.3
> 2 apple 1.5
> 3 apple 1.6
> 4 orange 1.4
> 5 orange 1.6
>
>
> x is a data frame.
> I want to extract unique items from fruits that has max weight.
>
> that is:
>
> 3 apple 1.6
> 5 orange 1.6
>
> I want to be able to use apply functions. Could some one lend some help please.
>
> Thanks
> srini
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list