Package 'similiars'

Title: Matches Strings to Most Similiar String
Description: Package to find similiarity between character vectors.
Authors: David Sjoberg [aut, cre]
Maintainer: David Sjoberg <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-10-19 20:55:44 UTC
Source: https://github.com/davidsjoberg/similiars

Help Index


case_when_skeleton

Description

Returns a case_when from dplyr to replace .s with .r. You can copy the output and put in the script to avoid manual work.

Usage

case_when_skeleton(.s, .r, var_name = NULL)

Arguments

.s

a character vector to be replaced.

.r

a character vector to replace with.

var_name

Optional. the name of the variable that should be replaced. If NULL or not changed the call of '.s' is used.

Value

console output with a case_when skeleton

Examples

case_when_skeleton(letters[1:10],
                   LETTERS[1:10],
                   var_name = "my_letters")

find_most_similar_string

Description

Returns a vector of most similar string in another vector. Returns a vector of the same length as input vector '.s'.

Usage

find_most_similar_string(
  .s,
  .t,
  max_dist = Inf,
  verbose = TRUE,
  ignore_case = TRUE,
  feeling_lucky = FALSE,
  ...
)

Arguments

.s

a character vector to be matched.

.t

a character vector to be matched against.

max_dist

the maximum string distance

verbose

should warnings be printed in the console.

ignore_case

should case be ignored? Default is TRUE.

feeling_lucky

if multiple most similar strings are found. Should the first one be returned?

...

other arguments passed to utils::adist.

Details

Uses the generalized Levenshtein distance. For more information type ?utils::adist in the console.

Value

a character vector

Examples

find_most_similar_string(c("battman", "Irn Man"), superheroes)

find_string_distance

Description

Returns a list of dataframes arranged by most similar strings.

Usage

find_string_distance(.s, .t, ignore_case = TRUE, ...)

Arguments

.s

a character vector to be matched.

.t

a character vector to be matchad against.

ignore_case

should case be ignored? Default is TRUE.

...

other arguments passed to utils::adist.

Details

Uses the generalized Levenshtein distance. For more information type ?utils::adist in the console.

Value

a list of dataframes

Examples

find_string_distance("battman", superheroes)

Famous super heroes

Description

A character vector with 46 super heroes

Usage

superheroes

Format

A character vector with 46 super heroes:

Source

https://www.britannica.com/topic/list-of-superheroes-2024795