Hi.  I am having trouble thinking of an easy way to grab rows out of a
data frame.  I want to select the rows with a median value when the
rows are similar.

A simple example is this table, which I could read into a data frame.
I would like to find a new data frame with only the rows with a median
value for the "c" column given a certain "a" value.

For example, the c values for deadlift rows are 13, 8, and 5, so the
row with a c value of 8 should show up in the output.

        a          b          c
     1  deadlift   7          13 
     2  squat      7          24
     3  clean      7          10
     4  deadlift   8           8
     5  squat      8          20
     6  clean      8           2
     7  deadlift   9           5
     8  squat      9          32
     9  clean      9          19

Result:

        a          b          c
     4  deadlift   8           8
     5  squat      8          20
     3  clean      7          10

It's more complicated in my case, because I have not just one "a"
column, but about eight columns that have to be the same.  I can do
this with clumsy loops, but I wonder whether there's a better way.

-- 
--Ed L Cashin            |   PGP public key:
  [EMAIL PROTECTED]        |   http://noserose.net/e/pgp/

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to