Thanks. 
 
I ended up breaking it up into two steps:
 
table_data<-table(data)
subset(table_data, table_data==max(table_data))
 
Thanks again.


--- On Mon, 1/26/09, Mike Lawrence <m...@thatmike.com> wrote:

From: Mike Lawrence <m...@thatmike.com>
Subject: Re: [R] Mode (statistics) in R?
To: jasonkrup...@yahoo.com
Cc: r-help@r-project.org
Date: Monday, January 26, 2009, 7:39 AM

Here's a rather convoluted way of finding the mode (or, at least, the
first mode):

x = round(rnorm(100,sd=5))
my_mode = as.numeric(names(table(x))[which.max(table(x))])




On Mon, Jan 26, 2009 at 9:28 AM, Jason Rupert <jasonkrup...@yahoo.com>
wrote:
> Hopefully this is a pretty simple question:
>
> Is there a function in R that calculates the "mode" of a sample?
  That is, I would like to be able to determine the value that occurs the most
frequently in a data set.
>
> I tried the default R "mode" function, but it appears to provide
a storage type or something else.
>
> I tried the RSeek and some R documentation that I downloaded, but nothing
seems to mention calculating the "mode".
>
> Thanks again.
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University
www.thatmike.com

Looking to arrange a meeting? Check my public calendar:
http://www.thatmike.com/mikes-public-calendar

~ Certainty is folly... I think. ~



      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to