numericalAsCharacter: Convert numeric values to character that sort correctly

Description Usage Arguments Details Value See Also Examples

View source: R/internalFunctions.R

Description

Small function that takes as input integer values (or values that can be converted to integer values) and converts them into character values that are 'padded' with zeros at the beginning of the numbers so that they will sort correctly.

Usage

1
numericalAsCharacter(values, prefix = "")

Arguments

values

vector of values to be converted into sortable character values

prefix

optional character string that will be added as prefix to the result

Details

The function determines the largest value and adds zeros to the front of smaller integers so that the resulting characters are the same number of digits. This allows standard sorting of the values to correctly sort.

The maximum number of zeros that will be added is 3. Input integers beyond that point will not be correctly fixed for sorting.

Negative integers will not be corrected, but left as-is

Value

A character vector

See Also

str_pad

Examples

1
numericalAsCharacter(c(-1, 5,10,20,100))

clusterExperiment documentation built on Feb. 11, 2021, 2 a.m.