Here are some random numbers replicated
x = sample(runif(10), 1000, TRUE)
Find unique values (optional, round to significant digits), then find the index of each xin the unique values table and place these
ux = sort(unique(x))
idx = match(x, ux)
n = tabulate(idx, nbins=length(ux))
finally summarize the results
df = data.frame(x=ux, n=n)
Use the summary to see all the values.
> head(df)
x n
1 0.02832152 108
2 0.04973473 90
3 0.19770913 96
4 0.31591234 103
5 0.59334322 97
6 0.64145901 98
or determine the values with the maximum number of samples
> df[df$n == max(df$n), , drop=FALSE]
x n
10 0.9711141 127
source
share