Learn R Programming

kutils (version 1.0)

zapspace: Convert leading or trailing white space and tab characters to nothing.

Description

This eliminates any characters matched by the regular expression `\s` if they appear at the beginning of a string or at its end. It does not alter spaces in the interior of a string

Usage

zapspace(x)

Arguments

x

A character vector

Value

If x is a character vector, return is a character vector with leading and trailing white space values removed. If x is not a character vector, an unaltered x is returned.

Examples

Run this code
# NOT RUN {
gg <- c("", " ", "   ", "\t", "\t some", "some\t", " space first")
(zapspace(gg))
# }

Run the code above in your browser using DataLab