Given the following sample, I'd like to iterate across each column. My result for the 3x3 matrix will provide a ratio based on how many elements in each column match.
m <- data.frame("c1" = c(1,0,0), "c2" = c(1,1,0), "c3" = c(0,0,1))
Example code to check columns:
> m[,1] == m
> m[,2] == m
> m[,3] == m
Output for m[,1] == m
c1 c2 c3
[1,] T, T, F
[2,] T, F, F
[3,] T, T, F
I'd like to sum up all of the results respectively.
example:
m[,1] 1 + 2/3 + 1/3
I think a nested loop could solve this problem.