Skip to content
Back to formatted view

Raw Message

Message-ID: <200306231639.LAA03733@uhddx01.dt.uh.edu>
Date: 2003-06-23T16:39:57Z
From: Erin Hodgess
Subject: Summary for mode of a data set

Dear R People:

thank you for the many helpful sets of code that I received!!!

I combined several of the concepts for the following function:

> mode1

function(x) {

        y <- rle(sort(x))

        z <- y$values[y$lengths==max(y$lengths)]

        return(z)

}

> xm

 [1] 22 15 10 30 25 26  2 17 28  2 24  6 26 24  5 22 20 14

> mode1(xm)

[1]  2 22 24 26

> 

This will pick up multiple modes.

Again thanks to all who helped!

Sincerely,
Erin 
mailto: hodgess at uhddx.01.dt.uh.edu