Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

strjust

Justify character vector


Description

Justify the strings in a character vector.

Usage

strjust(s, justify = c("left", "right", "center"))

Arguments

s

Character vector.

justify

Whether to justify left, right, or centered.

Details

strjust(s) or strjust(s, justify = ``right'') returns a right-justified character vector. All strings have the same length, the length of the longest string in s — but the strings in s have been trimmed before.

strjust(s, justify = ``left'') does the same, with all strings left-justified.

strjust(s, justify = ``centered'') returns all string in s centered. If an odd number of blanks has to be added, one blank more is added to the left than to the right.

Value

A character vector of the same length.

See Also

Examples

S <- c("abc", "letters", "1", "2  2")
strjust(S, "left")

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.