str_diff(x, y)
an integer vector containing the index of all mis-matched characters in the first string.
Computes which characters differ between two strings.
# strings to comparex <- "once upon a time"y <- "once upon a time there was"z <- "once upon two times"# diff: x - yd <- str_diff(x, y)donce upon a time ................---------- once upon a time there wasstr(d)Class 'str_diff' atomic (0) ..- attr(*, "str")=List of 2 .. ..$ x: chr "once upon a time" .. ..$ y: chr "once upon a time there was"# other comparisonsstr_diff(y, x)once upon a time there was ................++++++++++ once upon a timestr_diff(x, x)once upon a time ................ once upon a timestr_diff(x, z)once upon a time ..........******--- once upon two timesstr_diff(y, z)once upon a time there was ..........*********+++++++ once upon two times