0

Sorry, I know my question should have been answered somewhere, just I don't know how to find that. It would be great if someone could either redirect me to a post where the answer is, or write an answer here.

I have 2 data sets. First:

image_index <- c('a', 'a', 'b','b','c','c')
ET <- c(5, 7, 8, 3, 4, 6)
df_1 = data.frame(image_index, ET) 

Second

image_index <- c('a', 'b','c')
clouds <- c(0, 2, 0.5)
df_2 = data.frame(image_index, clouds)

I would like to join them so that each row in df_1 would have corresponding cloud cover value. So it would look like this

image_indexET clouds
a      5       0
a      7       0
b      8       2
b      3       2
c      4      0.5
c      6      0.5

I have tried to use merge, but the result I was able to get was different from what I wanted.

Thank you in advance!

Valerija
  • 25
  • 1
  • 8
  • `require(dplyr)` `full_join(df_1,df_2)` ? – count Aug 08 '17 at 11:55
  • When I try `merge(df_1, df_2)` it looks just like your desired output. What problems are you having with merge? – Andrew Brēza Aug 08 '17 at 11:58
  • have you tried `dplyr::left_join(df_1,df_2)` ? – Aramis7d Aug 08 '17 at 11:59
  • Thank you all!!! Sorry, I had a problem with the index. Haven't noticed that in the second data frame the name of the column image_index was over a different column. Just understood that after tried to use full_join and carefully reading error message. – Valerija Aug 08 '17 at 12:05

0 Answers0