strip_common_substring: remove starting or trailing substrings that ar the same for...

View source: R/util_generic.R

strip_common_substringR Documentation

remove starting or trailing substrings that ar the same for all strings in a vector

Description

eg; .txt in all filesnames, or ⁠<experiment data><samplename>⁠

Usage

strip_common_substring(s)

Arguments

s

array of strings

Examples

## Not run:  strip_common_substring(s = unique(peptides$sample_id)) 
## Not run:  strip_common_substring(s = c("sample_a.txt","sample_b1.txt","sample_xyz.txt")) 
## Not run:  strip_common_substring(s = c("","sample_b1.txt","sample_xyz.txt")) 
## Not run:  strip_common_substring(s = c("sample.txt","sample_b1.txt","sample_xyz.txt")) 
## Not run: 
  assertthat::are_equal(
    strip_common_substring(c("sample_a.txt","sample_b1.txt","sample_xyz.txt")),
    c("a","b1","xyz")
  )

## End(Not run)


ftwkoopmans/msdap documentation built on March 5, 2025, 12:15 a.m.