[R] Mode?

LONG Yu ylong at smu.edu.sg
Tue Nov 23 09:19:09 CET 2004

Dear all, 

I want to find out the mode for a data set, anyone knows how to do it in
I tried the codes below, but it seems too long:

tt<-table(data1)         #get the frequency tables of data1
oo<-order(tt);            #get the order of frequencies 
len<-length(tt)           #the length of the tables
mm<-oo[len];            #the last number of oo is the position  
tt[mm]                     #we can get the mode 

Thank you everybody first!

Long Yu

More information about the R-help mailing list