Hello,

I need help comparing two variables and producing a third variable with the
result.I have this data:

id <-c(1,2,3,4,5,6,7,8,9,10)
vi <-c(1,0,1,1,1,1,1,2,2,0)
vi2  <-c(0,1,1,1,1,1,1,2,0,0)
data<-cbind(id,vi,vi2)

For the data in the example, I need to generate:
id <-c(1,2,3,4,5,6,7,8,9,10)
correct <-c(0,0,1,1,1,1,1,1,0,1)
correct_data<-cbind(id,correct)

Matrix "correct_data"is the result of comparing "vi" with "vi2" and see if
they match. If the values are the same correct value=1 and if not correct
value=0 keeping the same id position.

How can I do this? I tried with match and with %in% but is not exactly what
I need.

Thanks in advance!

Inti Luna

	[[alternative HTML version deleted]]

