str: Pad Strings

strcenterR Documentation

Pad Strings

Description

strcenter adds char to the left and right of x to make its length n.

strrjust adds char to the left.

strljust adds char to the right.

Usage

strcenter(x, n = 1, char = " ", type = "c")
strrjust(x, n = 1, char = " ", type = "c")
strljust(x, n = 1, char = " ", type = "c")

Arguments

x

character vector.

n

numeric vector for the widths of the output. The first number is used for the first string in x, the second for the second, etc.

char

character string or vector of 1-characters for padding characters. The first character is used for the first string in x, the second for the second, etc.

type

character string: partial matching to one of c("bytes", "chars", "width"). See nchar.

Value

Character vector.

Examples

strrjust("hello", 10)
strljust("hello", 10)
strcenter("hello", 10)

graywh/r-gmisc documentation built on April 19, 2023, 1:42 p.m.