[R] mode of frequency distribution table
andrija djurovic
djandrija at gmail.com
Sun Jan 8 15:37:56 CET 2012
Hi. You can do something like this:
#find the most frequent values of x
> t <- table(x)
> t[t==max(t)]
5
8
#sort table t based on frequencies
> t[order(as.numeric(t),decreasing = TRUE)]
x
5 6 4 17 1 2 13 30 100 300
8 5 4 2 1 1 1 1 1 1
#extract any range from sorted table
> t[order(as.numeric(t),decreasing = TRUE)][1:3]
x
5 6 4
8 5 4
I hope this helps.
Andrija
On Sun, Jan 8, 2012 at 1:48 PM, Mary Kindall <mary.kindall at gmail.com> wrote:
> In a frequency distribution table (bell shaped), how can we find the most
> frequent range?
> for example:
>
> x = c(1,2, 4,4,4,4, 5,5,5,6,6,5,5,5,5,5,6,6,6,13, 17,17,30,100,300)
>
> barplot(table(x))
>
>
> In the code above, which function do we use to find that the most
> frequent value range from 4 to 6.
>
> Thanks.
>
>
>
> --
> -------------
> Mary Kindall
> Yorktown Heights, NY
> USA
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list