strs_center {strs} | R Documentation |
Center a string in a field of a given width
Description
strs_center
centers each element of a character vector in a field of a
specified width. It pads the string on both sides with a specified character
(defaulting to a space). This is similar to Python's str.center()
method.
Usage
strs_center(string, width, fillchar = " ")
Arguments
string |
A character vector where each element is a string to be centered. |
width |
The total width of the field in which the string is to be centered. |
fillchar |
A character used for padding. If not specified, defaults to a
space. Only the first character of |
Value
A character vector of the same length as string
, where each element
has been centered in a field of the specified width.
See Also
Python str.center() documentation
Examples
strs_center("hello", 10)
strs_center("world", 10, "*")
[Package strs version 0.1.0 Index]