jack jack - 1 year ago 67
R Question

How to return a Boolean vector that tells whether element in vector A is in vector B?

Suppose I have two vectors, A and B. I want to get a boolean vector with the same length of vector A, which tells the information of each element in vector A whether it is in vector B. What is the function for it?

Answer Source

I think you're looking for %in%:

A <- c(0,2,4,6)
B <- c(8,7,6,5,4)
A %in% B
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download