str_padding: Pad a string (with better defaults).

Description Usage Arguments Value See Also Examples

Description

These functions just wrap around stringr::str_pad() with some better defaults (imho). If width is missing it defaults to length of the string + 1 for str_lpad() and str_rpad() and + 2 for str_bpad().

Usage

1
2
3
4
5
str_lpad(string, width, pad = " ")

str_rpad(string, width, pad = " ")

str_bpad(string, width, pad = " ")

Arguments

string

A character vector.

width

Minimum width of padded strings.

pad

Single padding character (default is a space).

Value

a padded character vector.

See Also

stringr::str_pad() for more examples.

Examples

1
2
3
4
5
rbind(
  str_lpad("hadley", 30, "_"),
  str_rpad("hadley", 30, "-"),
  str_bpad("hadley", 30, "'")
)

tstev/tstevR documentation built on May 18, 2020, 10:57 p.m.