1
I’m having a question, I’d like to take the element a[1] and compare with b[1,1] and count as a hit, then the element a[2] compared to b[2,1] and so on, always by column. Then I want to compare the a[1] with b[1,2] and count as certain, then the item a[2] with the element b[2,2] and so on. Later return the column of b which got more hits.
set.seed(1)
a = sample(1:3, 4, replace = T)
b = matrix(sample(1:3, 20, replace = T), ncol = 5, byrow = T)
The desired answer would be column 2 or 5 that if tied I choose one of the columns randomly.
Thanks in advance.
It’s not very clear. You want to compare the vector
awith each of the matrix columns?– Daniel Falbel
That, element by element.
– Wagner Jorge
I edited a stupid question.
– Wagner Jorge