【发布时间】:2022-01-18 10:01:27
【问题描述】:
我正在尝试执行 2 列的匹配,但没有成功。我有一个DF1 2 列,Id 和JSON。在第二个DF2 中,我有一列与DF1$json 的每一行匹配的模式(类似于 vlookup + 类似函数)。
作为输出,我想得到DF1$Id,但只有DF2 中的任何一个与DF1$json 匹配。
我尝试了一些与str_detect 的组合,但它不适用于非向量值。也许有一些 grep 或 stringr 函数的技巧?
例如:
str_detect(DF1$json, fixed(DF2[1,1], ignore_case = TRUE))
【问题讨论】:
-
请使用
dput(DF1)和dput(DF2)分享reproductible example