chr.trim {misty} | R Documentation |
Trim Whitespace from String
Description
This function removes whitespace from start and/or end of a string
Usage
chr.trim(x, side = c("both", "left", "right"), check = TRUE)
Arguments
x |
a character vector. |
side |
a character string indicating the side on which to remove whitespace,
i.e., |
check |
logical: if |
Value
Returns a character vector with whitespaces removed from the vector specified
in x
.
Note
This function is based on the str_trim()
function from the stringr
package by Hadley Wickham.
Author(s)
Takuya Yanagida takuya.yanagida@univie.ac.at
References
Wickham, H. (2019). stringr: Simple, consistent wrappers for common string operations. R package version 1.4.0.
See Also
chr.grep
, chr.grepl
, chr.gsub
, chr.omit
Examples
x <- " string "
# Example 1: Remove whitespace at both sides
chr.trim(x)
# Example 2: Remove whitespace at the left side
chr.trim(x, side = "left")
# Example 3: Remove whitespace at the right side
chr.trim(x, side = "right")
[Package misty version 0.6.5 Index]