Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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. This was created when I was not aware of R's trimws and the purpose is the same. On our TODO list, we intend to eliminate this function and replace its use with trimws

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.

Author(s)

Paul Johnson <pauljohn@ku.edu>

Examples

x <-  c("", " ", "   ", "\t", "\t some", "some\t", " space first")
zapspace(x)

kutils

Project Management Tools

v1.70
GPL-2
Authors
Paul Johnson [aut, cre], Benjamin Kite [aut], Charles Redmon [aut], Jared Harpole [ctb], Kenna Whitley [ctb], Po-Yi Chen [ctb], Shadi Pirhosseinloo [ctb]
Initial release
2020-04-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.