trimws {memisc}R Documentation

Trim Leading and Trailing Whitespaces

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

  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

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

[Package memisc version 0.95-17 Index]