[R] Getting minimum value of a column according a factor column of a dataframe

@vi@e@gross m@iii@g oii gm@ii@com @vi@e@gross m@iii@g oii gm@ii@com
Thu Aug 25 18:31:35 CEST 2022


Yes, Timothy, the request was not seen by all of us as the same.

Indeed if the request was to show a subset of the original data consisting
of only the rows that were the minimum for each Code and also showed ties,
then the solution is a tad more complex. I would then do something along the
lines of what others showed such as generating another column showing the
minimum for each row and then showing only rows that matched their value in
two columns or whatever was needed.

As noted, keeping the output in a specific order was not initially
requested.

Keeping the data in some order is a common enough request but in this
situation, I suspect the order many might want would be the one showing the
minimums in order, not the codes in the original order. 

-----Original Message-----
From: Ebert,Timothy Aaron <tebert using ufl.edu> 
Sent: Thursday, August 25, 2022 11:59 AM
To: avi.e.gross using gmail.com
Cc: R-help using r-project.org
Subject: RE: [R] Getting minimum value of a column according a factor column
of a dataframe

My assumption (maybe wrong) was that we needed to keep the other variables.
I want to find the values of Y, M, D, N, and O for the minimum value of Q
within each unique value of Code, keeping the data in the original order.
All one need to do is filter Q in the original dataframe by your answer for
minQ.

Keeping the data in the original order seems unnecessary, but that is what
was asked in a later post.



More information about the R-help mailing list