这是开始的事情
library(stringdist) # install.packages("stringdist") b4, if you need to
df <- read.table(header = TRUE, text = "id firstname lastname emailaddress match
1 patrick boyles patrickb@gmail.com yes
2 zeke cosmos zeke@gmail.com yes
3 foo foo abcd@gmail.com no")
df$match2 <- ifelse(with(df, stringdist(a = paste0(firstname, lastname),
b = sub("(.*)@.*", "\\1", emailaddress),
method = "lcs")) <= 7,
"yes", "no")
df
# id firstname lastname email.address match match2
# 1 1 patrick boyles patrickb@gmail.com yes yes
# 2 2 zeke cosmos zeke@gmail.com yes yes
# 3 3 foo foo abcd@gmail.com no no