[R] mode of a data set

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Mon Jun 23 18:02:38 CEST 2003


Erin Hodgess wrote:
> Dear R People:
> 
> Is there a function to find the mode of a data set, please?
> 
> This is the mode as in the value(s) which occur most often.
> 

Erin,
   Will this work for you?

R> x <- rbinom(100, size = 20, prob = .2)
R> table.x <- table(x)
R> table.x[which.max(table.x)]
  4
23
R>

Regards,
Sundar




More information about the R-help mailing list