File: trimSpace.R

package info (click to toggle)
r-cran-seqinr 3.3-3-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,844 kB
  • ctags: 69
  • sloc: ansic: 1,955; makefile: 13
file content (11 lines) | stat: -rw-r--r-- 379 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
trimSpace <- function(x, leading = TRUE, trailing = TRUE, space = "[:space:]"){
  if(leading){
    pattern <- paste("^[", space, "]*", sep = "", collapse = "")
    x <- sub(pattern = pattern, replacement =  "", x = x)
  }
  if(trailing){
    pattern <- paste("[", space, "]*$", sep = "", collapse = "")
    x <- sub(pattern = pattern, replacement =  "", x = x)
  }
  return(x)
}