str_diff: Finding Differences Between Strings

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Computes which characters differ between two strings.

Usage

1
str_diff(x, y)

Arguments

x

a single string

y

a single string

Value

an integer vector containing the index of all mis-matched characters in the first string.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 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
str(d)

# other comparisons 
str_diff(y, x)
str_diff(x, x)
str_diff(x, z)
str_diff(y, z)

pkgmaker documentation built on Oct. 23, 2020, 6:40 p.m.

Related to str_diff in pkgmaker...