How to find most frequent element in an array?

It seems like you are looking for the mode function:

julia> using StatsBase

julia> mode([1, 3, 2, 1, 4, 1])
1
4 Likes