Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

str_diff

Finding Differences Between Strings


Description

Computes which characters differ between two strings.

Usage

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

# 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

Development Utilities for R Packages

v0.32.2
GPL (>= 2)
Authors
Renaud Gaujoux [aut, cre]
Initial release
2020-10-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.