Learn R Programming

textutils (version 0.4-1)

trim: Remove Leading and Trailing White Space

Description

Remove leading and/or trailing white space from character vectors.

Usage

trim(s, leading = TRUE, trailing = TRUE, perl = TRUE, ...)

Value

a character vector

Arguments

s

a character vector

leading

logical

trailing

logical

perl

logical

...

arguments passed to gsub

Author

Enrico Schumann

Details

trim removes leading and trailing space, which is defined through the (Perl) regular expression \s.

The base package has a function trimws these days, so you may not actually need the function (any more).

See Also

Examples

Run this code
s <- c("\t 2 2\n \t", "   ab  ")
trim(s)

Run the code above in your browser using DataLab