chr.trim | R Documentation |
This function removes whitespace from start and/or end of a string
chr.trim(x, side = c("both", "left", "right"), check = TRUE)
x |
a character vector. |
side |
a character string indicating the side on which to remove whitespace,
i.e., |
check |
logical: if |
Returns a character vector with whitespaces removed from the vector specified
in x
.
This function is based on the str_trim()
function from the stringr
package by Hadley Wickham.
Takuya Yanagida takuya.yanagida@univie.ac.at
Wickham, H. (2019). stringr: Simple, consistent wrappers for common string operations. R package version 1.4.0.
chr.grep
, chr.grepl
, chr.gsub
, chr.omit
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.