powered by
Remove leading and/or trailing white space from character vectors.
trim(s, leading = TRUE, trailing = TRUE, perl = TRUE, ...)
a character vector
logical
arguments passed to gsub
gsub
Enrico Schumann
trim removes leading and trailing space, which is defined through the (Perl) regular expression \s.
trim
\s
The base package has a function trimws these days, so you may not actually need the function (any more).
trimws
trimws, gsub, strtrim
strtrim
s <- c("\t 2 2\n \t", " ab ") trim(s)
Run the code above in your browser using DataLab