Skip to content
Prev 70468 / 398525 Next

a more elegant approach to getting the majority level

you could try this:

x <- factor(sample(letters[1:3], 20, TRUE))
#######
tab <- table(x)
names(tab)[tab == max(tab)]


I hope it helps.

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: "Rajarshi Guha" <rxg218 at psu.edu>
To: "R" <r-help at stat.math.ethz.ch>
Sent: Thursday, May 26, 2005 4:36 PM
Subject: [R] a more elegant approach to getting the majority level