Skip to contents

strs_rjust right-justifies each element of a character vector in a field of a specified width. It is similar to Python's str.rjust() method.

Usage

strs_rjust(string, width, fillchar = " ")

Arguments

string

A character vector where each element is a string to be right-justified.

width

The total width of the field in which the string is to be right-justified.

fillchar

A character used for padding on the left.

Value

A character vector of the same length as string, with each element right-justified in a field of the specified width.

Examples

strs_rjust("hello", 10)
#> [1] "hello     "
strs_rjust("world", 10, "*")
#> [1] "world*****"