str_just: Trim strings

Description Usage Arguments Author(s) Examples

View source: R/strings.R

Description

This function pads/trims strings to the desired length. When trimming, it also adds "..." to the end of strings to indicated that they have been trimmed.

Usage

1
str_just(x, n = 50, trail = "...", pad = NULL, side = "right")

Arguments

x

A character vector.

n

Desired length.

trail

Appended to strings that are longer than n.

pad

A string which will be used to pad short strings to the desired length.

side

Which side should be padded. Either "left", "right", or "both". Passed to stri_pad.

Author(s)

Kristian D. Olsen

Examples

1
2
3
4
5
x <- paste(letters[1:10], collapse = "")
a <- str_just(x, n = 8)
b <- str_just(x, n = 11, pad = " ")
identical(a, "abcde...")
identical(b, "abcdefghij ")

itsdalmo/reporttoolDT documentation built on May 18, 2019, 7:11 a.m.