I have two data frames that I would like to match similar columns in both data frames and extract the value of another column in one of the data tables.
I have tried the below code but it doesn`t work:
Code:
output <- if (Data_1$Var1 %in% Data_2$Coor) {
      Data_2$binID
      } else if (Data_1$Var2 %in% Data_2$Coor) {
        Data_2$ID
      } else {NA}
Data_1:
                  Var1                    Var2       value
 chr22:17400000-17410000 chr22:16080000-16090000  139.939677
 chr22:17400000-17410000 chr22:26080000-26090000  256.945265
 chr22:33470000-33480000 chr22:16080000-16090000  134.432441
Data_2:
                    coor  ID
 chr22:17400000-17410000  1
 chr22:33470000-33480000  2
 chr22:16080000-16090000  3
 chr22:26080000-26090000  4
Output:
                     ID1                    ID2       value
                       1                      3   139.939677
                       1                      4   256.945265
                       2                      3   134.432441
 
     
    