R/exportFct_ensureUniqueColumns.R

Defines functions exportFct_ensureUniqueColumns

exportFct_ensureUniqueColumns <- function(dat){
  # check whether any colnames are duplicated
  chkCols <- colnames(dat) %>% tolower
  isDupl <- duplicated(chkCols)
  if(any(isDupl)){
    newCols <- ifelse(isDupl, paste0(chkCols, "_2"), chkCols)
    colnames(dat) <- newCols
  }
  return(dat)
}
DoroChilds/TPP documentation built on Oct. 31, 2021, 4:38 a.m.