identify_common_string function

Identify shared leading or trailing character strings

Identify shared leading or trailing character strings

Compares all elements of a vector of numbers or character strings and returns TRUE if they are all the same, FALSE otherwise.

identify_common_string(strings, leading = TRUE)

Arguments

  • strings: vector of strings to be evaluated.
  • leading: boolean variable indicating whether the function should look for common strings at the beginning (leading==TRUE) or end (leading==FALSE) of the strings. Default is TRUE.

Returns

if there is a leading (if leading==TRUE) or trailing (if leading==FALSE) string that all elements of strings have in common, this string is returned; NA otherwise.

Examples

identify_common_string(c("Temp_01","Temp_02","Temp_03")) identify_common_string(c("Temp_01","Temp_02","Temp_03"),leading=FALSE) identify_common_string(c("file1.csv","file2.csv","file3.csv"),leading=FALSE)

Author(s)

Eike Luedeling

  • Maintainer: Eike Luedeling
  • License: GPL-3
  • Last published: 2024-11-14

Useful links