Last chance! 50% off unlimited learning
Sale ends in
Remove leading and/or trailing white space from character strings
removeSpace(x, begin = TRUE, end = TRUE, all = FALSE, ...)
Character string (vector)
Character string, can be a vector
Logical. Remove leading spaces at the beginning of the character string? DEFAULT: TRUE
Logical. Remove trailing spaces at the end? DEFAULT: TRUE
Logical. Remove all spaces anywhere in the string? DEFAULT: FALSE
Further arguments passed to sub
or gsub
, like ignore.case, perl, fixed, useBytes
.
Berry Boessenkool, berry-b@gmx.de, Dec 2014
s <- c("space at end ", " white at begin", " both ", " special ^ ")
removeSpace(s)
trimws(s)
# To add space, use:
x <- c("ab","abcde")
format(x)
format(x, justify="centre")
format(x, width=9)
Run the code above in your browser using DataLab