I have a ReGex, and, I think, a Tidyverse question.
I need to correct the spelling of "Missouri" in multiple unique strings. My goal is to keep the text surrounding the misspelling but replace only the misspelling ("old misosuri bank" to "old missouri bank").
Where I'm coming up short is how to accomplish this when the misspelling is flanked by differing strings without resorting to writing a specific gsub() for each unique string. See "#specific gsub of a type that I'd like to avoid using#" in the code chunk.
There has to be a way to use ReGex and Tidyverse to tell Rstudio, "Look for this misspelling in the Name variable regardless of where it occurs within a string and the identity of strings/characters flanking the misspelling. Then, replace only the misspelling while leaving the flanking strings/characters intact.", but I'll be darned if I can figure it out. (Will someone please tell the ReGex demons to stop that infernal cackling?)
I'd appreciate any suggestions you might have.
Thanks is advance.
#incorrect spellings incorrect_MO_spell <- c("old misosuri bank", "old misosuri bank", "southwest misosuri bank", "security bank of southwest misosuri", "regional misosuri bank","old misosuri bank", "first national bank of nevada misosuri","farmers state bank of northern misosuri", "missouri is spelled correctly") incorrect_MO_spell <- as_tibble(incorrect_MO_spell) colnames(incorrect_MO_spell) = c("Name") #specific gsub of a type that I'd like to avoid using# incorrect_MO_spell$value <- gsub("old misosuri bank", "old missouri bank",incorrect_MO_spell$value) #output with corrected spellings that I want correct_MO_spell <- c("old missouri bank", "old missouri bank", "southwest missouri bank", "security bank of southwest missouri", "regional missouri bank","old missouri bank", "first national bank of nevada missouri","farmers state bank of northern missouri", "missouri is spelled correctly") correct_MO_spell <- as_tibble(correct_MO_spell) colnames(correct_MO_spell) = c("Name")