sfill {dreamerr} | R Documentation |
Fills a string vector with a symbol
Description
Fills a string vector with a user-provided symbol, up to the required length.
Usage
sfill(x = "", n = NULL, symbol = " ", right = FALSE, anchor, na = "NA")
Arguments
x |
A character vector. |
n |
A positive integer giving the total expected length of each character string. Can be NULL (default). If |
symbol |
Character scalar, default to |
right |
Logical, default is |
anchor |
Character scalar, can be missing. If provided, the filling is done up to this anchor. See examples. |
na |
Character that will replace any NA value in input. Default is "NA". |
Value
Returns a character vector of the same length as x
.
Examples
# Some self-explaining examples
x = c("hello", "I", "am", "No-one")
cat(sep = "\n", sfill(x))
cat(sep = "\n", sfill(x, symbol = "."))
cat(sep = "\n", sfill(x, symbol = ".", n = 15))
cat(sep = "\n", sfill(x, symbol = ".", right = TRUE))
cat(sep = "\n", paste(sfill(x, symbol = ".", right = TRUE), ":", 1:4))
# Argument 'anchor' can be useful when using numeric vectors
x = c(-15.5, 1253, 32.52, 665.542)
cat(sep = "\n", sfill(x))
cat(sep = "\n", sfill(x, anchor = "."))
[Package dreamerr version 1.4.0 Index]