knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of similars is to match strings to the most similar string in another vector.
You can install the released version of similiars
with:
remotes::install_github("davidsjoberg/similiars")
find_most_similar_string
The main function included is find_most_similar_string
which returns a vector of the same length as the vector to be matched against another.
library(similiars) x <- c("battman", "Y-men", "Supergrl") find_most_similar_string(x, superheroes)
find_string_distance
The other function is find_string_distance
. It returns a list of dataframes for each word and how similar each string is to all matched strings. If you are not sure if there is a good match to be found it is good practise to use this function before using find_most_similar_string
.
find_string_distance(c("aple", "abna"), c("banana", "apple", "pineapple"))
case_when_skeleton
If you want manual control over which should be replaced you can create a case_when
code chunk to use in your script.
# Misspelled vector supr_heros <- c("Btman", "Supergrl", "Tor", "Capitan 'Murica") # Corrected vector super_heroes <- find_most_similar_string(supr_heros, superheroes) # Make case_when skeleton to replace case_when_skeleton(supr_heros, super_heroes)
If you find anything you want to improve, submit an issue :)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.