[Rd] Statistical mode

Kevin Wright
Fri, 27 May 2011 13:56:52 -0000

Arni,

Here are two examples:

R> statmode(iris)
Sepal.Length  Sepal.Width Petal.Length  Petal.Width      Species
         "5"          "3"        "1.4"
"0.2"     "setosa"
R> table(iris$Species)

    setosa versicolor  virginica
        50         50         50

R> library(lattice)
R> statmode(barley)
         yield        variety           year           site
    "20.63333"     "Svansota"         "1932"
"Grand Rapids"

My thoughts:
1. The mode is not so interesting for continuous data.  I would much rather
use something like density().
2. Both the iris and barley data sets are balanced (each factor level
appears equally often), and the current output from the statmode function is
misleading by only showing one level.
3. I think the describe() function in the Hmisc package is much more useful
and informative, even for introductory stat classes.  I always use
describe() after importing data into R.

Kevin



On Thu, May 26, 2011 at 3:26 PM, Arni Magnusson <arnima@hafro.is> wrote:

> One descriptive statistic that is conspicuously missing from core R is the
> statistical mode - the most frequent value in a discrete distribution.
>
> I would like to propose adding the attached 'statmode' (or a
similar
> function) to the 'stats' package.
>
> Currently, it can be quite cumbersome to calculate the mode of a
> distribution in R, both for experts and beginners. The lack of a function
to
> do this is felt, both when teaching introductory R courses, and when using
> sapply() or the like.
>
> Looking forward to your feedback,
>
> Arni
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

	[[alternative HTML version deleted]]