strPad: Pad a string to minimum width

View source: R/strPad.R

strPadR Documentation

Pad a string to minimum width

Description

Pad a string to minimum width

Usage

strPad(x, width, side = c("left", "right"), pad = " ")

Arguments

x

character. Character vector that does not contain NA or empty strings.

width

integer(1). Padding width.

side

character(1). Apply padding to the left or right side.

pad

character(1). Single padding character.

Value

character.

Note

Updated 2023-09-21.

See Also

  • stringr::str_pad().

  • sprintf().

  • https://stringr.tidyverse.org/articles/from-base.html

Examples

x <- c("1", "10", "100")
width <- max(nchar(x))
x <- strPad(x = x, width = width, side = "left", pad = "0")
print(x)

acidgenomics/r-acidbase documentation built on Jan. 12, 2024, 3:56 a.m.