【发布时间】:2019-06-02 10:07:16
【问题描述】:
df1
df2
df3
library(dplyr)
library(fuzzyjoin)
df1 <- tibble(a =c("Apple Pear Orange", "Sock Shoe Hat", "Cat Mouse Dog"))
df2 <- tibble(b =c("Kiwi Lemon Apple", "Shirt Sock Glove", "Mouse Dog"),
c = c("Fruit", "Clothes", "Animals"))
# Appends 'Animals'
df3 <- regex_left_join(df1,df2, c("a" = "b"))
# Appends Nothing
df3 <- stringdist_left_join(df1, df2, by = c("a" = "b"), max_dist = 3, method = "lcs")
我想使用字符串将 df2 的 c 列附加到 df1, “苹果”、“袜子”和“老鼠狗”。
我尝试使用 regex_join 和 fuzzyjoin 执行此操作,但字符串的顺序似乎很重要,而且似乎找不到解决方法。
【问题讨论】:
标签: r regex string-matching fuzzyjoin