title: match words between two data frame in R
body: <p>I'm working in R and I have two data frames in Arabic language as shown here is a sample of the data set :
  <strong>Dataset 1:</strong> vocab</p>
  
  <pre><code>    term
  1:   شكرا
  2:    رقي
  3: تضيعون
  4:   ابكي
  </code></pre>
  
  <p><strong>Dataset 2:</strong> posneg</p>
  
  <pre><code>    score     words 
  1      ابكي      0
  2      تضيعون     0
  3      خسرت     0
  4      ظلمونا     0
  5      لا     0
  6      مستهتر     0
  7      وبلا     0
  8      احباط     0
  9      تفشلتوا     0
  10      خسرتم     0
  11      عقدتك     0
  12      للاسف     0
  13      مشكله     0
  29      اضاع     0
  30      حاقده     0
  31      خطا     0
  32      غير     0
  33      ما     0 
  116     ابدعوا     1
  117     اهنيكم     1
  118     حبا     1
  119     شكرا     1
  120     فرحه     1
  121     ممتاز     1
  122     وزعيما     1
  123     اجتهد     1
  124     باهر     1
  125     حبك     1
  126     صحيح     1
  127     فزت     1
  </code></pre>
  
  <p>I need to compare between <code>term</code> column in data 1 and <code>words</code> column in data 2 so if any word in <code>term</code> column in data 1 match any word in words column in data 2 gives it the same score, and if the word not match I want to write (new). Here is the result that i expect:</p>
  
  <pre><code>  score      term
  1:   شكرا     1 
  2:   1       رقي 
  3:   0      تضيعون
  4:   0        ابكي
  </code></pre>
  
  <p>here is the code the I wrote
  but get an error.</p>
  
  <pre><code> n&lt;-length(vocab$term)
    n2&lt;-length(posneg$words)
  
  
        for (i in 1:n) {
          if (vocab$term[i] == for (o in 1:n2) { posneg$words[o]}) 
            {
          vocab &lt;- cbind(vocab, "score" = posneg$score[o] )} #add new column)
          else{
            vocab &lt;- cbind(vocab, "score" = "no") #add new column
              }
          }
  </code></pre>
  
  <p>hope you understand me, thank you! </p>