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 (default), 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.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")

misty documentation built on June 29, 2024, 9:07 a.m.

Related to chr.trim in misty...