I would like to know how I can calculate the majority vote step by step, for example, comparing column 1 with 2, per line , then 1,2 and 3, per line , then 1, 2, 3 and 4, per line , and so on.
set.seed(1)
a = matrix(sample(1:6, 30, replace = T), ncol = 5)
That is, I get the line i
I compare all the elements, I calculate the element that appears the most times and return the same, being output as an array with i
rows and j-1
columns.