0

I am working with R and I have two data sets that look like this

Condition    Word
   1         hot
   1         dog
   1         cat
   1         floor
   1         food
   2         spike
   2         vital
   2         protein
   2         water
   2         people
   2         room
   3         sky
   3         bed
   3         sheet
   3         toilet

And I have a second tibble that looks like this....

Condition    Word        Score1     Score2
   1         hot            1         2
   1         play           3         4
   1         earth          3         1
   1         dog            2         4
   1         cat            4         1
   1         paint          1         4
   1         floor          2         3
   1         food           3         1
   2         spike          3         3 
   2         house          2         2
   2         wife           1         1 
   2         vital          2         4
   2         protein        4         4
   2         water          4         1
   2         people         4         3 
   2         dead           4         2 
   2         room           2         1
   3         sky            3         1
   3         grief          1         1 
   3         bed            1         2 
   3         computer       3         4
   3         laptop         4         3
   3         sheet          2         1 
   3         cup            1         4
   3         style          2         3
   3         toilet         3         1

So, the words that I nee are the ones that are in the first data set, but with the values that appear in the second dataset.

In other words, I need the first list with their respective values in the second list.

This is...

 Condition    Word        Score1     Score2
   1         hot            1         2
   1         dog            2         4
   1         cat            4         1
   1         floor          2         3
   1         food           3         1
   2         spike          3         3 
   2         vital          2         4
   2         protein        4         4
   2         water          4         1
   2         people         4         3 
   2         room           2         1
   3         sky            3         1
   3         bed            1         2 
   3         sheet          2         1 
   3         toilet         3         1

Thanks

Ajrhjnd
  • 330
  • 1
  • 9
  • I think it is a just `merge(df1, df2, all.x = TRUE)` – akrun Jul 27 '21 at 22:16
  • It takes all the extra values that the second data frame has. I only need the values of the first data frama. – Ajrhjnd Jul 27 '21 at 22:28
  • 1
    That is why i used `all.x = TRUE` where `df1` is the first data. I get your expected output from the above code (with the data you showed) – akrun Jul 27 '21 at 22:29

0 Answers0