spaces: String spacing functions

View source: R/spacing.R

spacesR Documentation

String spacing functions

Description

These functions create strings of spaces, pad strings with space, trim edge spaces, and squeeze out unnecessary spaces.

Usage

spaces(n)

pad(..., n = 0, s = "r", p = " ")

sqz(...)

trm(...)

Arguments

n

A complete positive whole-number scalar indicating the number of spaces or the number of pad characters.

...

An arbitrary number of atomic arguments to be processed.

s

A complete onechar scalar indicating side(s) to pad: 'l', 'r', or 'b' for left, right, or both, respectively.

p

A complete onechar scalar containing a single character used to pad strings.

Details

  spaces   Creates a character scalar of n spaces.
   
  pad Pads strings with leading, trailing white space using stringr::str_pad.
   
  sqz Trims leading, trailing, and extra internal white space using stringr::str_squish.
   
  trm Trims leading and trailing white space using stringr::str_trim.

Value

A character scalar

  spaces

A character object

  ⁠pad, trm, sqz⁠

See Also

Other strings: blank(), chn(), delim(), fsub(), gr, ipat(), makestr(), markdown_help(), maxnch(), ox(), ox_vals(), pgrid_help(), revstr(), ss_help(), tocase(), weave()

Other chars: chn(), maxnch(), revstr(), ss_help()

Examples

spaces(0)
spaces(4)
pad(0:9, n = 3)
pad(0:9, n = 3, s = "r")
pad(0:9, n = 3, s = "l")
pad(0:9, n = 3, s = "b")
pad(0:9, n = 3, s = "b", p = "*")
trm(c("a ", "b", "c", " ", "d  ", ""))
sqz(c("a ", "b", "c", " ", "d  ", ""))
sqz(trm(c("a ", "b", "c", " ", "d  ", "")))

j-martineau/uj documentation built on Sept. 14, 2024, 4:40 a.m.