trimws

0th

Percentile

Remove Leading/Trailing Whitespace

Remove leading and/or trailing whitespace from character strings.

Keywords
character
Usage
trimws(x, which = c("both", "left", "right"))
Arguments
x
a character vector
which
a character string specifying whether to remove both leading and trailing whitespace (default), or only leading ("left") or trailing ("right"). Can be abbreviated.
Details

For portability, ‘whitespace’ is taken as the character class [ \t\r\n] (space, horizontal tab, line feed, carriage return).

Aliases
  • trimws
Examples
library(base) x <- " Some text. " x trimws(x) trimws(x, "l") trimws(x, "r")
Documentation reproduced from package base, version 3.2.0, License: Part of R 3.2.0

Community examples

Looks like there are no examples yet.