Learn R Programming

memisc (version 0.11-11)

trimws: Trim leading and/or trailing whitespace

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

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

Run the code above in your browser using DataLab