trimws: Trim Leading and Trailing Whitespaces

Description Usage Arguments Value Examples

Description

trimws returns a character string with leading and/or trailing whitespaces removed. This is just a shorthand for an appropriate call to sub.

Usage

1
  trimws(x,left=TRUE,right=TRUE)

Arguments

x

a character vector

left

logical, if TRUE leading whitespace is removed

right

logical, if TRUE trailing whitespace is removed

Value

The character vector x with whitespace removed.

Examples

1
2
3
4
  teststr <- c(" Hello World!   ","I am here.  ")
  trimws(teststr)
  trimws(teststr,left=FALSE)
  trimws(teststr,right=FALSE)

mutils documentation built on May 2, 2019, 4:44 p.m.

Related to trimws in mutils...