R: I have to do Softmatch in String

后端 未结 2 1422
天命终不由人
天命终不由人 2020-12-17 06:16

I have to do softmatch in one column of data frame with the given input string, like

col <- c(\"John Collingson\",\"J Collingson\",\"Dummy Name1\",\"Dummy         


        
2条回答
  •  半阙折子戏
    2020-12-17 06:39

    It seems that agrep is the function you are looking for. It does Approximate String Matching (Fuzzy Matching). It returns the closest match to the input pattern according to some distance measure, i.e. the generalized Levenshtein edit distance. See ?agrep for more details.

    agrep("J Collingson", col, value = TRUE)
    [1] "John Collingson" "J Collingson"  
    

提交回复
热议问题