Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Ignoring the case for maxDist in stringdist::extract

I am using the stringdist package in R.

For several options:

grab(x, pattern, maxDist = Inf, value = FALSE, ...)

grabl(x, pattern, maxDist = Inf, ...)

extract(x, pattern, maxDist = Inf, ...)

it uses maxDist. This option however counts the distance between A and a as one. Just as the distance between A and b. I would like ignore the letter case, for maxDist. Does anyone know how?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use tolower and write your pattern in lowercase to ignore case:

x <- "Abc"
stringdist::extract(x, pattern = "abd", maxDist = 1)
#>      [,1]
#> [1,] NA
stringdist::extract(tolower(x), pattern = "abd", maxDist = 1)
#>      [,1] 
#> [1,] "abc"

Created on 2021-11-04 by the reprex package (v2.0.1)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading