oce (version 1.2-0)

unduplicateNames: Rename duplicated character strings

Description

Append numeric suffices to character strings, to avoid repeats. This is used by various data input functions, to handle the fact that several oceanographic data formats permit the reuse of variable names within a given file.

Usage

unduplicateNames(strings, style = 1)

Arguments

strings

Vector of character strings.

style

An integer giving the style. If style is 1, then e.g. a triplicate of "a" yields "a", "a1", and "a2". If style is 2, then the same input yields "a_001", "a_002", and "a_003".

Value

Vector of strings with repeats distinguished by suffix.

See Also

Used by read.ctd.sbe() with style=1 to rename repeated data elements (e.g. for multiple temperature sensors) in CTD data, and by read.odf() with style=2 on key-value pairs within ODF metadata.

Examples

Run this code
# NOT RUN {
unduplicateNames(c("a", "b", "a", "c", "b"))
unduplicateNames(c("a", "b", "a", "c", "b"), style=2)
# }

Run the code above in your browser using DataCamp Workspace