[R-sig-Geo] select a row in a data.frame

Fernando Miguez miguez at illinois.edu
Wed Oct 14 03:40:14 CEST 2009


Hi Gianni,

See also which.max

Fernando

Dan Putler wrote:
> Hi Gianni,
> 
> First the chide, you are asking a general (very beginner) R question on
> the Geospatial Special Interest Group mailing list, which isn't the
> right list for your question. The closest to the correct list is R-Help,
> but this is really something one learns from books on R, which there are
> a number of, and often available in online in PDF (start with An
> Introduction to R, http://cran.r-project.org/doc/manuals/R-intro.pdf).
> 
> Now the answer to your question:
> 
> BestResult_R <- newData[newData$result == max(newData$result), ]
> 
> Dan Putler
> 
> On Tue, 2009-10-13 at 16:59 -0700, gianni lavaredo wrote:
>> thanks for help,
>>
>> I have a data.frame "newData" with 7 columns and 91 rows. i wish to find the
>> row in the second column "X" with the max value and save all 7 values (=all
>> columns) in a new data.frame
>>
>>  # max value result for row
>>  Max.Result <- max(newData$result)
>>  select the row with the max value
>>  row <- which(Max.Result  == max(Max.Result ))
>>  BestResult_R <- newData[row,]
>>
>> but I have a same problems to set right the code.
>>
>> thanks
>>
>> Gianni
>>
>> 	[[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Fernando E. Miguez
Energy Biosciences Institute
http://netfiles.uiuc.edu/miguez/www/



More information about the R-sig-Geo mailing list