Computes which characters differ between two strings.
str_diff(x, y)
x | a single string |
---|---|
y | a single string |
an integer vector containing the index of all mis-matched characters in the first string.
# strings to compare x <- "once upon a time" y <- "once upon a time there was" z <- "once upon two times" # diff: x - y d <- str_diff(x, y) d#> once upon a time #> ................---------- #> once upon a time there was#> 'str_diff' Named int(0) #> - attr(*, "names")= chr(0) #> - attr(*, "str")=List of 2 #> ..$ x: chr "once upon a time" #> ..$ y: chr "once upon a time there was"# other comparisons str_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