search for: correct_data

Displaying 1 result from an estimated 1 matches for "correct_data".

2012 Aug 26
1
Comparing two variables for match and creating a new vector with results
...oducing 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...