fillUpStr | R Documentation |
Adds characters to the head or tail of each element of the character vector to make all elements the same length.
fillUpStr(strVec, howManyToFill, where, fill)
strVec |
A vector of character strings. |
howManyToFill |
The target number of characters in each element of |
where |
Where to place the characters: at the beginning of each element ( |
fill |
What character to add. The default is a blank space. |
The function adds characters to the head or tail of each element of the character vector, strVec
, so that all elements have the same number of characters. NA
values are returned unchanged. If howManyToFill
is NULL
or less than the number of characters in the longest element of strVec
, then the number of characters in the longest element is used.
A character string with equal number of characters in each element.
Svetlana K Eden, svetlanaeden@gmail.com
fillUpStr(c("A", "aaa", NA, "bb", "4.5"), where="tail", howManyToFill = 4, fill = "_") fillUpStr(c("A", "aaa", NA, "bb", "4.5"), where="tail", howManyToFill = -3, fill = "_") fillUpStr(c("A", "aaa", NA, "bb", "4.5"), where="head", howManyToFill = -3, fill = "*")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.