Given the following:
a <- c(1,2,3)
b <- c(1,2,3)
c <- c(4,5,6)
A <- cbind(a,b,c)
I want to find which columns in A are equal to for example my vector a.
My first attempt would be:
> which(a==A)
[1] 1 2 3 4 5 6
Which did not do that. (Too be honest I don't even understand what that did) Second attempt was:
a==A
a b c
[1,] TRUE TRUE FALSE
[2,] TRUE TRUE FALSE
[3,] TRUE TRUE FALSE
which definitely is a step in the right direction but it seems extended into a matrix. What I would have preferred is something like just one of the rows. How do I compare a vector to columns and how do I find columns in a matrix that are equal to a vector?