尝试使用library("stringi")
和:
df1$CheckEmail <- stri_detect_fixed(df1$Email, df1$Surname)
下面是一个使用基础R的方法mapply
有grepl
:
transform(df, CheckEmail = mapply(grepl, Surname, Email)) # Surname Email CheckEmail #1 house greghouse@gmail.com TRUE #2 wilson johnwatson@gmail.com FALSE