我要基于两个数据帧合并,如果一个数据帧中两个不同列的两个值位于另一个数据帧的列中
答案 0 :(得分:3)
这是一个fuzzyjoin
/ stringr
解决方案:
library(fuzzyjoin); library(stringr)
fuzzy_inner_join(df_b, df_a,
by = c("full_sql" = "column_name"),
match_fun = str_detect)
# full_sql index Table_name column_name freq
#1 UPDATE DDADMIN.USER_MASTER SETTERMINATED_USER_FLAG=:C19, TERMINATION_DATE=:C21 3694 DDADMIN.USER_MASTER SETTERMINATED_USER_FLAG 2
#2 UPDATE DDADMIN.USER_MASTER SETTERMINATED_USER_FLAG=:C19, TERMINATION_DATE=:C21 3694 DDADMIN.USER_MASTER TERMINATION_DATE 2
#3 UPDATE DDADMIN.USER_MASTER SETTERMINATED_USER_FLAG='N', TERMINATION_DATE=NULL 3695 DDADMIN.USER_MASTER SETTERMINATED_USER_FLAG 2
#4 UPDATE DDADMIN.USER_MASTER SETTERMINATED_USER_FLAG='N', TERMINATION_DATE=NULL 3695 DDADMIN.USER_MASTER TERMINATION_DATE 2