Dear Alessandro,
Here is one way:

DF <- data.frame(ID,a1,a2,a3,a4)
Row <- which( DF == max(DF[,-1]),  arr.ind = TRUE)[1]
DF[Row,]
#   ID a1 a2 a3 a4
#  10 10 10 20 30 40

See ?which and ?max for more details.

HTH,

Jorge


On Sun, Apr 26, 2009 at 8:02 AM, Alessandro <alessandro.monta...@unifi.it>wrote:

> Dear User,
>
>
>
> thank for the attention. I have a data.frame with 5 columns (ex:ID,
> a1,a2,a3,a4) and 1000 rows. I wish to find the absolute max value for all
> data.frame and save a new data.frame with the row where is that value. Ex:
>
>
>
> ID: 1,2,3,4,5,6,7,8,9,10
>
> a1:1,2,3,4,5,6,7,8,9,10
>
> a2:11,12,13,14,15,16,17,18,19,20
>
> a3:21,22,23,24,25,26,27,28,29,30
>
> a4:31,32,33,34,35,36,37,38,39,40
>
>
>
>
>
> The max value in the four columns (a1,a2,a3,a4) is 40. The new data.frame
> is
>
>
>
> ID:10
>
> A1:10
>
> A2:20
>
> A3:30
>
> A4 :40
>
>
>
> Thanks
>
>
>
> Ale
>
>
>        [[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