R: Make string numbers comply with alphabetical order.

str_alphord_nums {strex} | R Documentation

## Make string numbers comply with alphabetical order.

### Description

If strings are numbered, their numbers may not comply with alphabetical order, i.e. "abc2" comes after "abc10" in alphabetical order. We might (for whatever reason) wish to change them such that they come in the order that we would like. This function alters the strings such that they comply with alphabetical order, so here "abc2" would be renamed to "abc02". It works on file names with more than one number in them e.g. "abc01def3" (a string with 2 numbers). All the file names that it works on must have the same number of numbers, and the non-number bits must be the same.

### Usage

    str_alphord_nums(strings)

### Arguments

`strings` | A vector of strings.

### Examples

    strings <- paste0("abc", 1:12)
    strings
    str_alphord_nums(strings)
    str_alphord_nums(c("abc9def55", "abc10def7"))
    str_alphord_nums(c("01abc9def55", "5abc10def777", "99abc4def4"))
    str_alphord_nums(1:10)

    ## Not run:
    str_alphord_nums(c("abc9def55", "abc10xyz7"))
    ## End(Not run)

[Package strex version 0.1.3 Index]