I\'m wondering how I can compare 1 element of a vector with all elements in the other vector. As an example: suppose
x <- c(1:10) y <- c(10,11,12,13,
If you want to compare each element of x to y, usually one of the 'apply' functions will help.
As follows:
x <- c(1:10) y <- c(10,11,12,13,14,1,7) sapply(x,function(z){z==y})
x <- c(1:10)
y <- c(10,11,12,13,14,1,7)
sapply(x,function(z){z==y})
Column i in the output is result from x[i]==y.
Is this what you're looking for?