commonSuffix | R Documentation |
Finds and returns the longest suffix common to all strings in a character
vector. Can be set to ignore case, in which case the returned common string
will be in lower case. If any strings are NA
, this returns NA
unless dropNA= TRUE
is set, which will drop NA
s before
checking for a common suffix
commonSuffix(x, ignoreCase = FALSE, dropNA = FALSE)
x |
The strings to find the longest common suffix for. |
ignoreCase |
Set this true to match suffixes even if they differ in case. |
dropNA |
Set this true to ignore |
The common suffix, if any, or "", if no common suffix can be found.
commonPrefix
commonSuffix( c( "ABCDE", "CDE", "cDE" ))
#=> [1] "DE"
commonSuffix( c( "ABC", "abc", "def" ))
#=> [1] ""
commonSuffix( c( "ABCDE", "CDE", "" ))
#=> [1] ""
commonSuffix( c( "ABCDE", "ABCDE", NA ))
#=> [1] NA
commonSuffix( c( "A\u00dfC", "A\u00dfC", "a\u00dfC" ))
#=> [1] "ßC"
commonSuffix( c("ABCDE", "CDE", "cDE" ), ignoreCase= TRUE )
#=> [1] "cde"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.