I have two vectors like this:
vec1<-c(0, 0, 1, 1, 0, 0, 0, 0, 0, 0)
vec2<-c(0, 0, 0, 1, 0, 0, 1, 0, 1, 0)
I want to merge it somehow to turn it into this:
vec<-c(0, 0, 1, 1, 0, 0, 1, 0, 1, 0)
Is there any way to do this?
I have two vectors like this:
vec1<-c(0, 0, 1, 1, 0, 0, 0, 0, 0, 0)
vec2<-c(0, 0, 0, 1, 0, 0, 1, 0, 1, 0)
I want to merge it somehow to turn it into this:
vec<-c(0, 0, 1, 1, 0, 0, 1, 0, 1, 0)
Is there any way to do this?
Here is a solution with ifelse:
ifelse(vec1==0 & vec2==0, 0, 1)
[1] 0 0 1 1 0 0 1 0 1 0