Function that pads strings to be the same
length, with padding applied either to the
left or right-hand side.
align_strings(strings, left = TRUE)
Arguments
- strings
A character vector.
- left
Logical; if TRUE
left-aligns strings, otherwise
right-aligns strings.
Value
A character vector.
Examples
# Strings of unequal length
x <- c( "A", "BB", "CCC" )
# Left-aligned
s <- align_strings( x )
message( paste0( '|', s, '|\n' ) )
#> |A |
#> |BB |
#> |CCC|
# Right-aligned
s <- align_strings( x, FALSE )
message( paste0( '|', s, '|\n' ) )
#> | A|
#> | BB|
#> |CCC|