Format strings for pretty output

surround(x, pre = " ", post = " ", width = 8, ...)

Arguments

x

a vector

pre

text to prepend onto string

post

text to postpend onto string

width

desired width of string

...

additional arguments passed to format()

Value

a vector of strings padded to the desired width

Examples

surround(rbinom(10,20,.5), " ", " ", width=4)
#>  [1] " 15 " "  7 " " 11 " " 12 " " 12 " "  9 " " 11 " " 10 " " 10 " " 11 "
surround(rnorm(10), " ", " ", width=8, digits = 2, nsmall = 2)
#>  [1] " -0.8772 " " -1.0317 " "  0.3526 " " -0.3711 " " -0.0014 " " -0.5178 "
#>  [7] " -0.8977 " "  0.1890 " " -1.2624 " " -0.7017 "