-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Thomas Lumley
Sent: Friday, November 12, 2004 10:44 AM
To: Vito Ricci
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] Mode in case of discrete or categorial data
On Fri, 12 Nov 2004, Vito Ricci wrote:
Mode<-function(x){t<-table(x)
if (is.numeric(x)) as.numeric(names(t)[t == max(t)]) else
== max(t)]) }
Any other improvement and suggestion will welcome.
which.max is design for finding the maximum, so
names(t)[which.max(t)]
-thomas