Learn R Programming

assertive (version 0.2-6)

truncate: Truncate a string

Description

Truncates a character vector to have a maximum length.

Usage

truncate(x, width = getOption("width"))

Arguments

x
A character vector, or something coercible to one.
width
A positive integer.

Value

  • A character vector

Examples

Run this code
truncate(c("abcd", "efghi", "jklmno", "pqrstuv"), 5)

Run the code above in your browser using DataLab