bestMismatch: Find fewest mismatches

View source: R/leven.R

bestMismatchR Documentation

Find fewest mismatches

Description

Find fewest mismatches (and position if desired) between pattern and string without allowing gaps. Could be programmed better but quick enough for now.

Usage

bestMismatch(
  pattern,
  subject,
  pos = findAll,
  weights = rep(1, nchar(pattern)),
  findAll = FALSE,
  dummyChar = "|"
)

Arguments

pattern

String pattern to search for in subject

subject

Subject string to search in

pos

If TRUE return position in addition to distance

weights

Integer weights for each position of pattern

findAll

If TRUE return all best matches

dummyChar

A character that does not appear in either string (only necessary if findAll==TRUE [and could probably program better])

Value

Single value giving the least mismatch if pos=FALSE, c(minMismatches,position) if pos=TRUE, if findAll==TRUE matrix with columns minMismatches, position and rows for each occurrence

Author(s)

Scott Sherrill-Mix R@sherrillmix.com


sherrillmix/levenR documentation built on Oct. 25, 2023, 11:42 a.m.