str_pad2: Pad a string.

Description Usage Arguments Value Note Author(s) Examples

View source: R/fct_str_pad2.R

Description

Vectorised over 'string', 'width' and 'pad'. This is an internal function doing the same thing of [stringr::str_pad] (except for parameters ''width'‘ and '’length'' which must be of length 1), but without depending on package 'stringi'.

Usage

1
str_pad2(string, width, side = c("left", "right", "both"), pad = " ")

Arguments

string

A character vector.

width

Minimum width of padded strings.

side

Side on which padding character is added (left, right or both).

pad

Single padding character (default is a space).

Value

A character vector.

Note

License: GPL 3.0

Author(s)

Luigi Ranghetti, phD (2019) luigi@ranghetti.info

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
rbind(
  str_pad2("hadley", 30, "left"),
  str_pad2("hadley", 30, "right"),
  str_pad2("hadley", 30, "both")
)

# All arguments are vectorised except side
str_pad2(c("a", "abc", "abcdef"), 10)

# Longer strings are returned unchanged
str_pad2("hadley", 3)

pobsteta/shinyCNES documentation built on April 28, 2021, 9:43 a.m.