LCSn: Find longest common substring from 'n' strings.

View source: R/fcn_misc.R

LCSnR Documentation

Find longest common substring from 'n' strings.

Description

Warning: greedy heuristic! This is not guaranteed to find the best solution (or any solution at all), since its done pairwise with the shortest input string as reference.

Usage

LCSn(strings, min_LCS_length = 0)

Arguments

strings

A vector of strings in which to search for LCS

min_LCS_length

Minimum length expected. Empty string is returned if the result is shorter

Value

longest common substring (or "" if shorter than min_LCS_length)

Examples

LCSn(c("1_abcde...",
       "2_abcd...",
       "x_abc..."))  ## --> "_abc"
LCSn(c("16_IMU008_CISPLA_E5_R11", 
       "48_IMU008_CISPLA_P4_E7_R31",
       "60_IMU008_CISPLA_E7_R11"), 3) ## -->"_IMU008_CISPLA_"
LCSn(c("AAAAACBBBBB", 
       "AAAAADBBBBB",
       "AAAABBBBBEF",
       "AAABBBBBDGH")) ## -->  "BBBBB"
LCSn(c("AAAXXBBB",
       "BBBXXDDD",
       "XXAAADDD")) ## --> fails due to greedy approach; should be "XX"


PTXQC documentation built on May 29, 2024, 9:26 a.m.