Glue sequential padded numbers within each group of repeated names
Source:R/uniquify_names.R
uniquify_names.Rd
Note: tabname cleaning and parameter checks should already have been done in scrub_tabnames before passing args. This function is recursive and can call itself forever if width, sep, and pad aren't checked in advance.
Usage
uniquify_names(
tabnames,
truncate_side = "right",
paste_side = "right",
width = 31,
sep = "->",
pad = ".",
ellipsis = "",
quiet = FALSE
)
Arguments
- tabnames
character vector of tab/sheet names
- truncate_side
snip excess tabnames on 'left', 'right', or 'center'
- paste_side
'left', 'right' for side of the tabnames to tack on rownumbers
- width
number of chars allowed in the tab/sheet name
- sep
tabname text and rownumber separator
- pad
padding characters used on left side of group rownumbering
- ellipsis
replacement characters during truncation
- quiet
quiet warning reports
Examples
tabnames = c('', NULL, NULL, NA, NA, 'a', 'a', 'a', 'b', 'b', 'c', rep('d',11))
uniquify_names(tabnames)
#> ! Duplicate or empty names exist. Numbering within each group ...
#> [1] "->1" "NA->1" "NA->2" "a->1" "a->2" "a->3" "b->1" "b->2" "c"
#> [10] "d->.1" "d->.2" "d->.3" "d->.4" "d->.5" "d->.6" "d->.7" "d->.8" "d->.9"
#> [19] "d->10" "d->11"
uniquify_names(tabnames = tabnames, paste_side = 'left' , sep = '|')
#> ! Duplicate or empty names exist. Numbering within each group ...
#> [1] "1|" "1|NA" "2|NA" "1|a" "2|a" "3|a" "1|b" "2|b" "c" ".1|d"
#> [11] ".2|d" ".3|d" ".4|d" ".5|d" ".6|d" ".7|d" ".8|d" ".9|d" "10|d" "11|d"