left: Get a substring from the left

View source: R/all.R

leftR Documentation

Get a substring from the left

Description

Inspired by the Excel function with the same name.

Usage

left(string, n)

Arguments

string

a vector of strings

n

a vector of integers (will be recycled, if needed)

Value

The first n characters of each value in string. If n has length 1, then that value is applied to all strings because of recycling. However, n can have more than one element!

Examples

left('lazy dog', 4)
left(c('lazy dog', 'blue dog'), 4)
left(c('lazy dog', 'red dog'), c(4, 3))


adamleerich/alrtools documentation built on March 12, 2024, 11:38 p.m.