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. Thanks so much! R for Windows, v 1.7.0 Sincerely, Erin Hodgess mailto: hodgess at uhddx.01.dt.uh.edu
On Monday 23 June 2003 17:50, 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. >x[rev(order(table(x)))[1]] is this what you want? regards Adelchi Azzalini -- Adelchi Azzalini <azzalini at stat.unipd.it> Dipart.Scienze Statistiche, Universit? di Padova, Italia http://azzalini.stat.unipd.it/
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
Dear Erin, Assuming that by "data set" you mean a vector "v", then sort(table(v)) will give you what you want. On Mon, 23 Jun 2003, Erin Hodgess wrote:> Date: Mon, 23 Jun 2003 10:50:47 -0500 (CDT) > From: Erin Hodgess <hodgess at uhddx01.dt.uh.edu> > To: r-help at stat.math.ethz.ch > Subject: [R] mode of a data set > > 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. > > Thanks so much! > > R for Windows, v 1.7.0 > > Sincerely, > Erin Hodgess > mailto: hodgess at uhddx.01.dt.uh.edu > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >J.R. Lockwood 412-683-2300 x4941 lockwood at rand.org http://www.rand.org/methodology/stat/members/lockwood/