numerate: Formats a Sequence of Numbers with Zero Padding

View source: R/CodeAndRoll2.R

numerateR Documentation

Formats a Sequence of Numbers with Zero Padding

Description

This function generates a sequence of numbers between two specified values, optionally padding them with leading zeros to a specified length. It is useful for creating numeric sequences with consistent character lengths.

Usage

numerate(
  x = 1,
  y = 100,
  zeropadding = TRUE,
  pad_length = floor(log10(max(abs(x), abs(y)))) + 1
)

Arguments

x

The starting number of the sequence. Default: 1.

y

The ending number of the sequence. Default: 100.

zeropadding

Logical; whether to pad numbers with zeros. Default: TRUE.

pad_length

The length of padding for the numbers. Default: Calculated as floor(log10(max(abs(x), abs(y)))) + 1.

Value

A vector of formatted numbers, with or without zero padding.

See Also

str_pad

Examples

numerate(1, 122)

vertesy/CodeAndRoll2 documentation built on Nov. 20, 2024, 5:23 a.m.