View source: R/adjustStrings.R
adjustStrings | R Documentation |
Adjust the size of character strings by adding extra characters. It allows to constraint the size of the string or to add a specific number of extra characters.
adjustStrings( x, n, extra = 0, align = c("right", "left", "center"), add = FALSE )
x |
a character vector, or a vector to be coerced to a character vector. |
n |
a positive integer indicating the size of character strings to be created or added. |
extra |
a character vector, or a vector to be coerced to a character vector that will be (partially) added to produced a string of a specific length. |
align |
either "right", "left" or "center". If "right", then strings
will be right-aligned and so |
add |
a logical should |
This function was originally created to help getting a fixed number of digits when naming files. The current version is more general, it allows to add any string before or after to adjust the size. Not that if a character is longer than expected, it will be adequately cut off.
A character vector of the concatenated characters.
base::sprintf()
paste0('myfilename', adjustStrings(c(1:2,10,100), 3)) adjustStrings('# Comment ', 20, '#', align = "left")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.