merge data with partial match in r

前端 未结 2 1433
天涯浪人
天涯浪人 2020-12-30 14:33

I have two datasets

datf1 <- data.frame (name = c(\"regular\", \"kklmin\", \"notSo\", \"Jijoh\",
 \"Kish\", \"Lissp\", \"Kcn\", \"CCCa\"),
 number1 = c(1         


        
2条回答
  •  孤城傲影
    2020-12-30 15:00

    agrep will get you started.

    something like:

    lapply(tolower(datf1$name), function(x) agrep(x, tolower(datf2$name)))
    

    then you can adjust the max.distance parameter until you get the appropriate amount of matching. then merge however you like.

提交回复
热议问题