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.
unduplicateNames(strings, style = 1)
Vector of character strings.
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"
.
Vector of strings with repeats distinguished by suffix.
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.
# 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 DataLab