Re: [R] Finding Values that Occur Most Often in a Vector

2008-07-09 Thread Duncan Mackay
If you just want the value which is the most frequent try as.numeric(names(which.max(table(c( -295.8045 ,-295.8045, -295.8045, -295.8045 ,-325.4754 ,-295.8045, -295.8045, -295.8045, -413.2099, -295.8045) [1] -295.8045 There may be easier ways Regards Duncan Mackay Department of Agronomy

Re: [R] Finding Values that Occur Most Often in a Vector

2008-07-09 Thread hpages
Hi Gundala, This would be a way to do it: names(which.max(table(myvector))) For example: > set.seed(99) > y <- sample(letters[1:3], 40, replace=TRUE) [1] "b" "a" "c" "c" "b" "c" "c" "a" "b" "a" "b" "b" "a" "b" "c" "b" [17] "b" "a" "a" "a" "a" "a" "c" "b" "c" "b" "a" "c" "a" "a" "b"

[R] Finding Values that Occur Most Often in a Vector

2008-07-09 Thread Gundala Viswanath
Hi, Is there a way to do it? For example I have the following vector: > print(myvector) > [1] -295.8045 -295.8045 -295.8045 -295.8045 -325.4754 -295.8045 -295.8045 [8] -295.8045 -413.2099 -295.8045 I want it to return -295.8045, which occur most often. - Gundala Viswanath Jakarta - Indonesia