Skip to content

Mode?

4 messages · LONG Yu, Dimitris Rizopoulos, Uwe Ligges +1 more

#
Dear all, 

I want to find out the mode for a data set, anyone knows how to do it in
R? 
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!

Regards, 
Long Yu
#
Hi Yu,

this has been recently discussed in the list, look at:

http://tolstoy.newcastle.edu.au/R/help/04/11/7054.html


Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm



----- Original Message ----- 
From: "LONG Yu" <ylong at smu.edu.sg>
To: <r-help at stat.math.ethz.ch>
Sent: Tuesday, November 23, 2004 9:19 AM
Subject: [R] Mode?
#
LONG Yu wrote:

            
See ?which.max

Uwe Ligges
#
Yhe question of finding the mode of a dataset has been discussed previously in
the list not only for categorical data :

search "How can I get the mode" in the search engine of the list.

Hope this helps.

Romain.

Selon Uwe Ligges <ligges at statistik.uni-dortmund.de>: