adist_dels: Approximate Distance allowing only for deletions

View source: R/write_COSEROreg_par.r

adist_delsR Documentation

Approximate Distance allowing only for deletions

Description

Calculate the approximate distance of two strings returning the matches, where deletions where necessary only.

Usage

adist_dels(x, y, dels = NULL, returnstrings = FALSE, warn = FALSE)

Arguments

x

string or vector of strings that the function will try to transform into y

y

string that the function uses to transform x into

dels

NULL or integer. If NULL (the default) set no limitations on how many deletions are allowed. If dels is an integer, allow only that many deletions as dels is set.

returnstrings

logical. Should the strings be returned (TRUE) or the positions within x.

warn

logical. Activate or deactivate warnings.

Details

This function calls adist to calculate the approximate distance and the operations (insertions, substitutions and deletions) necessary to transform string x in string y. It then evaluates only the cases, where deletions where made only. The user may set a maximum of allowed deletions. If the transformation fails it throws a warning (if warn == TRUE) and return NA.

Value

a string (vector) or a numerical (vector)

Author(s)

Simon Frey

Examples

   y <- c("PCOR", "TCOR", "TMMON", "INTMAX", "ETVEGCOR", "DAYSDRY", "DAYSWET", "ETSYSCOR")
   x <- "PCor1"
   
   adist_dels(x,y, dels = 1, returnstrings = TRUE)
   
   x <- "PCORXXX"
   
   adist_dels(x,y, dels = 1)
   adist_dels(x,y, dels = NULL)

freysimon/TigR documentation built on April 20, 2024, 9:28 p.m.