Learn R Programming

textutils (version 0.4-1)

valign: Vertically Align Strings

Description

Vertically align character vectors.

Usage

valign(s, align = "|", insert.at = "<>", replace = TRUE, fixed = TRUE)

Value

a character vector

Arguments

s

a character vector

align

a regular expression

insert.at

a regular expression

replace

logical

fixed

logical

Author

Enrico Schumann

Details

The function expands the elements of a character vector in such a way that the elements are vertically aligned, which can be handy when generating reports. See Examples.

See Also

Examples

Run this code
s <- c("Player 1 <>| 100",
       "another player <>| 999999")

cat(paste(s, collapse = "\n"))
## Player 1 <>| 100
## another player <>| 999999

cat(paste(valign(s), collapse = "\n"))
## Player 1        100
## another player  999999

Run the code above in your browser using DataLab