Automatically generate a substring and add trailing "..." if necessary.

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

Arguments

x

Object.

width

integer(1). Width.

Value

character.

Details

Note that return matches the desired width.

Note

Updated 2019-12-05.

See also

assertive.base:::truncate().

Examples

x <- "the quick brown fox" x <- shorten(x, width = 10L) nchar(x)
#> [1] 10