Skip to contents

Takes a character vector containing a range of numeric IDs (e.g. "11 - 14") and replaces the range with the numbers contained in the range ("11 12 13 14").

Usage

range_to_vector(numbers, separator = " ")

Arguments

numbers

Character vector containing a number range indicated by a dash (e.g. "123 - 456"). Numbers outside of range must be separated by whitespace (e.g. "1 3 5-9"). Number range can be ascending or descending but cannot contain negative numbers. "-123 - 456" is NOT valid input. No non-numeric characters are permitted, except for whitespace and dashes.

separator

Character string to use as a separator between numbers in output.

Value

The same character vector, but with number ranges removed and replaced with the numbers in the range explicitly listed.

Details

Does NOT work with negative numbers.