strip | R Documentation |
strip
removes leading and trailing white space from each element of a
character vector. White space characters include tab, newline, vertical tab,
form feed, carriage return, space and possible other locale-dependent
characters.
strip(x)
x |
a character vector, or an object which can be coerced by
|
strip
returns a character vector of the same length and with the same
attributes as x
(after possible coercion to character). Elements of
character vectors x
which are not substituted will be returned
unchanged (including any declared encoding).
x <- c(
" the quick brown fox jumps over a lazy dog ",
" the quick brown fox jumps over a lazy dog\t\n"
)
strip(x) # the leading and trailing tab, newline, and space are removed
## x is intended to be in encoding latin1
x <- "fa\xE7ile"
Encoding(x) <- "latin1"
y <- strip(x)
## since 'x' has no leading or trailing white space, 'strip(x)' retains the
## encoding of 'x'
Encoding(y)
y
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.