# --- Setup ---
cell_types <- c(
"B cell", "T cell", "Macrophage", "Monocyte", "Neutrophil",
"Natural Killer T-cell", "Dendritic cell"
)
# --- Usage ---
# 1. Exact match (after normalization)
suggest_best_match("t cell", cell_types)
#> [1] "T cell"
# 2. Typo correction (fuzzy match)
suggest_best_match("Macrophaeg", cell_types)
#> [1] "Macrophage"
# 3. Partial input (substring match)
suggest_best_match("Mono", cell_types)
#> [1] "Monocyte"
# 4. Requesting multiple suggestions
suggest_best_match("t", cell_types, n = 3)
#> [1] "T cell" "Neutrophil" "Natural Killer T-cell"
# 5. No good match found
suggest_best_match("Erythrocyte", cell_types)
#> [1] NA
# 6. Returning suggestions with their distance score
suggest_best_match("t ce", cell_types, n = 3, return_distance = TRUE)
#> suggestion distance
#> 1 T cell 1
#> 2 Dendritic cell 2
#> 3 Natural Killer T-cell 2
Run the code above in your browser using DataLab