Reputation: 47
I have two vectors with equal length containing 0 and 1, but are not identical:
a <- c(1,1,0,1,1,1,0,1,1,0,0,1)
b <- c(1,1,0,0,1,0,0,0,1,1,1,1)
I want to create a new vector according to following if-rules, I tried
c <- ifelse((a==1 & b==1),1,0) |
ifelse((a==0 & b==0),0,1) |
ifelse((a==1 & b==0),0,1) |
ifelse((a==0 & b==1),0,1)
but was not working... Does anyone has an idea how to realize this?
Upvotes: 0
Views: 81
Reputation: 78
c <- a*b
Upvotes: 4