alignStrings {pnd} | R Documentation |
Align printed output to the longest argument
Description
Align printed output to the longest argument
Usage
alignStrings(x, names = NULL, pad = c("l", "c", "r"))
Arguments
x |
A numeric vector or matrix to be aligned with a vector of column names. |
names |
Optional: if x does not have (column) names, a character vector of element
or column names to be output first. Ignored if |
pad |
A single character: |
Value
A character matrix with the first row of names and the rest aligned content
Examples
x <- structure(1:4, names = month.name[1:4])
print(alignStrings(x, names(x)), quote = FALSE)
print(alignStrings(x, names(x), pad = "c"), quote = FALSE) # Centring
print(alignStrings(x, names(x), pad = "r"), quote = FALSE) # Left alignment
x <- matrix(c(1, 2.3, 4.567, 8, 9, 0), nrow = 2, byrow = TRUE)
colnames(x) <- c("Andy", "Bradley", "Ci")
alignStrings(x, pad = "c")
[Package pnd version 0.1.0 Index]