DescTools (version 0.99.14)

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

Description

Returns the left part or the right part Of a string.

Usage

StrLeft(x, n)
StrRight(x, n)

Arguments

x
a vector of strings
n
the number of characters to cut. n will be recycled.

Value

  • the left (right) n characters of x

Details

The function StrLeft is a simple wrapper to substr.

See Also

substr, StrTrim

Examples

Run this code
StrLeft("Hello world!", n=5)
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))

Run the code above in your browser using DataCamp Workspace