padstr: Pad a string and align within string

View source: R/tostring.R

padstrR Documentation

Pad a string and align within string

Description

Pad a string and align within string

Usage

padstr(x, n, just = list_valid_aligns(), fontspec = font_spec())

Arguments

x

(string)
a string.

n

(integer(1))
number of characters in the output string. If n < nchar(x), an error is thrown.

just

(string)
text alignment justification to use. Defaults to "center". Must be one of "center", "right", "left", "dec_right", "dec_left", or "decimal".

fontspec

(font_spec)
a font_spec object specifying the font information to use for calculating string widths and heights, as returned by font_spec().

Value

x, padded to be a string of length n.

Examples

padstr("abc", 3)
padstr("abc", 4)
padstr("abc", 5)
padstr("abc", 5, "left")
padstr("abc", 5, "right")

## Not run: 
# Expect error: "abc" has more than 1 characters
padstr("abc", 1)

## End(Not run)


formatters documentation built on Sept. 13, 2024, 1:10 a.m.