Here's my modest contribution:

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)
        }

(I called it 'smode' because there's a 'mode' func somewhere which is related to the data type or something)

Carl

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to