1

In this, I would like search from final_df_input based on columns Item & LC from the dataframe lctolc.

I want 2 dataframe outputs

  1. Which is having the elements Item,LC of final_df_input in lctolc
  2. Which is not having elements Item,LC of in lctolc

final_df_input

Item <- c("A", "A", "A", "A", "B", "B")
LC <- c("MW92", "OY01", "RM11" ,"LO99", "WK14", "RS11")
SS <- c(20, 10, 5, 99, 112, 30)
Freq <- c(0, 0, 1, 0, 0, 1)
final_df_input <- data.frame(Item, LC, SS, Freq, stringsAsFactors = F)

  Item   LC     SS Freq
1   A   MW92    20  0
2   A   OY01    10  0
3   A   RM11    5   1
4   A   LO99    99  0
5   B   WK14    112 0
6   B   RS11    30  1

lctolc

Item <- c("A", "A", "A", "B", "B")
LC <- c("MW92", "OY01", "RM11", "WK14", "RS11")
ToLC <- c("OY01", "RM11", "RM02", "RS11", "ZM78")
lctolc <- data.frame(Item, LC, ToLC, stringsAsFactors = F)

   Item  LC     ToLC
1   A   MW92    OY01
2   A   OY01    RM11
3   A   RM11    RM02
4   B   WK14    RS11
5   B   RS11    ZM78

Output 1:

  Item   LC     SS Freq
1   A   MW92    20  0
2   A   OY01    10  0
3   A   RM11    5   1
4   B   WK14    112 0
5   B   RS11    30  1

Output 2:

  Item   LC     SS Freq
1   A   LO99    99  0
Anshul S
  • 281
  • 1
  • 5

0 Answers0