Is there a function in R that helps me find the fashions of a multimodal dataset?

0

Something of the type EncontraModa (Dataset, N_Mores_Modas)?

I'm working with the following integers:     c (1,2,3,4,5,6,7,7,7,8,8,9,9,9,9,9)

That is, the example is trimodal and has a larger fashion than the other two.

The ideal would be perhaps to create a function that puts all integers and order and subtracts the next one from the previous one, when it gives the sum to a fashionable N variable and then compare those N fashionable variables? I'm trying to develop the code for this but I still can not.

    
asked by anonymous 09.02.2018 / 21:03

1 answer

4

Correcting the function of this site, link :

statmod <- function(x) {
  z <- table(as.vector(x))
  names(z)[z == max(z)]
}

a <- c(1,2,3,4,5,6,7,7,7,8,8,8,9,9,9,9)

statmod(a)

a
[1] "9"

Having 7, 8 and 9 with the same amount of repetitions, that is, same fashion:

b <- c(1,2,3,4,5,6,7,7,7,8,8,8,9,9,9)

statmod(b)

b
[1] "7" "8" "9"
    
09.02.2018 / 23:28