How to find the statistical mode?

前端 未结 30 1648
时光取名叫无心
时光取名叫无心 2020-11-21 07:00

In R, mean() and median() are standard functions which do what you\'d expect. mode() tells you the internal storage mode of the objec

30条回答
  •  天涯浪人
    2020-11-21 07:46

    This hack should work fine. Gives you the value as well as the count of mode:

    Mode <- function(x){
    a = table(x) # x is a vector
    return(a[which.max(a)])
    }
    

提交回复
热议问题