Learn R Programming

chillR (version 0.75)

identify_common_string: Identify shared leading or trailing character strings

Description

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

Usage

identify_common_string(strings, leading = TRUE)

Value

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.

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.

Author

Eike Luedeling

Examples

Run this code

  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)
    

Run the code above in your browser using DataLab