I'm working in R and I have two data frames in Arabic language as shown here is a sample of the data set : Dataset 1: vocab
term
1: شكرا
2: رقي
3: تضيعون
4: ابكي
Dataset 2: posneg
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
I need to compare between term
column in data 1 and words
column in data 2 so if any word in term
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:
score term
1: شكرا 1
2: 1 رقي
3: 0 تضيعون
4: 0 ابكي
here is the code the I wrote but get an error.
n<-length(vocab$term)
n2<-length(posneg$words)
for (i in 1:n) {
if (vocab$term[i] == for (o in 1:n2) { posneg$words[o]})
{
vocab <- cbind(vocab, "score" = posneg$score[o] )} #add new column)
else{
vocab <- cbind(vocab, "score" = "no") #add new column
}
}
hope you understand me, thank you!