Padding a string with justification, insertion
Pad a string, insert substring.
pad(str, space,just = c("right", "left", "center", "none"), with=" " ) justify(str, space, just = c("right", "left", "center", "none"), with=" ") insstr(str, ins, point=nchar(str) )
str, ins |
String to be modified, to insert. |
space |
Integer, resulting length of padded string. |
just |
Mode of padding, of justification, one of "left","right","center", partial
matching is allowed. If missing, "right" is taken, meaning
for pad(just="r") right-ways extended (i.e. flush left), for justify(just="r") right-justified; "none" returns |
with |
String to pad with, will be repeated as often as necessary. |
point |
Integer, place of insertion. Appending is done for default value. |
pad, justify
: The string padded with with
.
insstr
The string contained in ins
inserted after character
number point
of str
.
pad(just="r") right-ways extended (i.e. flush left),
justify(just="r") right-justified,
just="none" returns str
unchanged.
Christian W. Hoffmann <christian@echoffmann.ch>
pad("My string",25,"c","XoX") # [1] "XoXXoXXoMy stringXXoXXoXX" pad("My string",25) # left aligned (str <- paste00(LETTERS)) # "ABCDEFGHIJKLMNOPQRSTUVWXYZ" pad(str, 37, "right", " $ ") insstr(str," $ ",7) # "ABCDEF $ GHIJKLMNOPQRSTUVWXYZ"
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.