chr.trim: Trim Whitespace from String

View source: R/chr.trim.R

chr.trimR 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., "both" (default), "left" or "right".

check

logical: if TRUE, argument specification is checked.

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.gsub, chr.omit

Examples

x <- "  string  "

# Remove whitespace at both sides
chr.trim(x)

# Remove whitespace at the left side
chr.trim(x, side = "left")

# Remove whitespace at the right side
chr.trim(x, side = "right")

misty documentation built on Nov. 15, 2023, 1:06 a.m.

Related to chr.trim in misty...