问题描述:

This question already has an answer here:

  • Is there a built-in function for finding the mode?

    25 answers

网友答案:

Here's another approach:

smode <-function(x){
    xtab<-table(x)
    modes<-xtab[max(xtab)==xtab]
    mag<-as.numeric(modes[1]) #in case mult. modes, this is safer
    themodes<-names(modes)
    mout<-list(themodes=themodes,modeval=mag)
    return(mout)
    }
相关阅读:
Top