StrRight: Returns the Left Or the Right Part Of a String

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/DescTools.r

Description

Returns the left part or the right part of a string. The number of characters are defined by the argument n. If n is negative, this number of characters will be cut off from the other side.

Usage

1
2
StrLeft(x, n)
StrRight(x, n)

Arguments

x

a vector of strings.

n

a positive or a negative integer, the number of characters to cut. If n is negative, this number of characters will be cut off from the right with StrLeft and from the right with StrRight.
n will be recycled.

Details

The functions StrLeft and StrRight are simple wrappers to substr.

Value

the left (right) n characters of x

Author(s)

Andri Signorell <andri@signorell.net>

See Also

substr, StrTrim

Examples

1
2
3
4
5
6
7
8
9
StrLeft("Hello world!", n=5)
StrLeft("Hello world!", n=-5)

StrRight("Hello world!", n=6)
StrRight("Hello world!", n=-6)

StrLeft(c("Lorem", "ipsum", "dolor","sit","amet"), n=2)

StrRight(c("Lorem", "ipsum", "dolor","sit","amet"), n=c(2,3))

DescTools documentation built on June 17, 2021, 5:12 p.m.