Skip to contents

This functions lets the user extract the first or last n characters of a string or vector of strings.

Usage

left(string, n = 1)

right(string, n = 1)

Arguments

string

String or Vector.

n

Integer. How many characters starting on right/left?

Value

Character. Trimmed strings.

Examples

left("Bernardo", 3)
#> [1] "Ber"
right(c("Bernardo", "Lares", "V"), 3)
#> [1] "rdo" "res" "V"