getCommonPrefix | R Documentation |
This function finds the longest common prefix shared by the input strings. This is different from finding the longest common substring as here we are insisting that this occur at the beginning of each of the strings. This uses a straightforward search, terminating whenever it finds a mismatch in any of the strings.
getCommonPrefix(words, asCharacter = TRUE, na.rm = TRUE)
words |
a character vector containing the strings of interest |
asCharacter |
a logical value which if |
na.rm |
a logical value indicating whether to remove |
If asCharacter
is TRUE
, a character vector giving the
actual prefix. If there is no common prefix, this is the empty
character vector.
If words
is empty, this returns the empty character vector
if asCharacter
is TRUE
and 0 otherwise.
If asCharacter
is FALSE
, this returns a
scalar integer giving the position of the end character
of the common prefix string.
Duncan Temple Lang <duncan@wald.ucdavis.edu>
http://www.omegahat.org/Rlibstree
getLongestCommonSubstring
# The names of enumerated constants in Microsoft Word's
# scripting interface. We want to find the common prefix.
enumNames = c('wdSummaryModeHighlight',
'wdSummaryModeHideAllButSummary',
'wdSummaryModeInsert',
'wdSummaryModeCreateNew')
getCommonPrefix(enumNames)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.