Finding maximum value of one column (by group) and inserting value into another data frame in R

后端 未结 3 509

All,

I was hoping someone could find a solution to an issue of mine that isn\'t necessarily causing headaches, but, as of right now, invites the possibility for huma

3条回答
  •  無奈伤痛
    2020-12-07 05:06

    It sounds like you're just looking for aggregate:

    > aggregate(cbind(x1, x2, x3, x4) ~ country1 + year, Data, max)
      country1 year x1 x2 x3 x4
    1        B 1998 30 10 30  2
    2        A 2000 95 90 25 90
    3        C 2005 90 90  5 40
    

    It's not very clear from your question how you want to proceed from there though....

提交回复
热议问题