[R] Finding the difference between two vectors

anna lippelanna24 at hotmail.com
Tue Feb 2 16:34:23 CET 2010


Hello everyone,
I have two vectors having only one element different:
                           vector1         vector2                       
vector1

                           TWC             TWC                            
TWC
                           VFC              TWX                            
NA 
                          VIA/B             VFC                             
VFC
                          WHR             VIA/B                            
VIA/B
                           WPO             WHR   --------->>>        WHR
                           WYN             WPO                            
WPO
                           WYNN          WYN                              
WYN
                           YUM            WYNN                            
WYNN
                           NA               YUM                              
YUM
In that case, in the first vector, the value twx is missing . What I want to
do is doing the following avoiding loop:
putting the NA row in front of the TWX row as this would be the row where
the value is missing. I don't know if there is any function doing this. I
thought about using a which() function to retrieve all the missing elements
index ( twx, 1 here) and insert them in the right index in the first vector
but how can I insert in a vector, is there an appropriated function? thank
you

-----
Anna Lippel
-- 
View this message in context: http://n4.nabble.com/Finding-the-difference-between-two-vectors-tp1460020p1460020.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list