group_numbers {artpack}R Documentation

Convert Numbers into Padded Strings for Easier Group Numbering

Description

Convert Numbers into Padded Strings for Easier Group Numbering

Usage

group_numbers(numbers)

Arguments

numbers

A numeric vector with a length of at least 1.

Value

A Character Vector

Examples

# Useful for easier group numbering so groups are ordered as intended
# Expects a numeric vector of numbers to convert to padded numbers
regular_numbers <- 1:19
padded_numbers <- group_numbers(regular_numbers)

# The padding matters when creating labels for groupings
# as numbers will be converted to characters if attached to strings.
# Sorts as expected:
sort(regular_numbers)

# Does not as a character:
sort(paste0("group_", regular_numbers))

# Will sort as expected when padded:
sort(paste0("group_", padded_numbers))

[Package artpack version 0.1.0 Index]