Selecting Max Column Values in R

后端 未结 2 868
甜味超标
甜味超标 2020-12-11 20:43

I\'m pretty new to R and have a question regarding selecting the max values in a column.

I have the following data frame:

          X      Y
 [1,]            


        
2条回答
  •  孤街浪徒
    2020-12-11 21:01

    You can use ave with a custom function that wraps max, so you can remove NA values:

    Data$Y <- ave(Data$Y, Data$X, FUN=function(x) max(x, na.rm=TRUE))
    

提交回复
热议问题