removeSpace {berryFunctions}R Documentation

Remove white spaces from strings

Description

Remove leading and/or trailing white space from character strings

Usage

removeSpace(x, begin = TRUE, end = TRUE, all = FALSE, ...)

Arguments

x

Character string, can be a vector

begin

Logical. Remove leading spaces at the beginning of the character string? DEFAULT: TRUE

end

Logical. Remove trailing spaces at the end? DEFAULT: TRUE

all

Logical. Remove all spaces anywhere in the string? DEFAULT: FALSE

...

Further arguments passed to sub or gsub, like ignore.case, perl, fixed, useBytes.

Value

Character string (vector)

Note

If all arguments are FALSE, the string is returned unchanged.
Not extensively tested yet, please mail me any problems...

Author(s)

Berry Boessenkool, berry-b@gmx.de, Dec 2014

See Also

sub

Examples


s <- c("space at end     ", "  white at begin", "  both ", " special ^  ")
removeSpace(s)

# To add space, use:
x <- c("ab","abcde")
format(x)
format(x, justify="centre")
format(x, width=9)


[Package berryFunctions version 1.20.1 Index]