ropensci / writexl

Portable, light-weight data frame to xlsx exporter for R
https://docs.ropensci.org/writexl
Other
210 stars 17 forks source link

Minor speedup opportunity in write_xlsx() #45

Open sindribaldur opened 4 years ago

sindribaldur commented 4 years ago
  if(any(nchar(names(x)) > 31)){
    warning("Truncating sheet name(s) to 31 characters")
    names(x) <- substring(names(x), 1, 29)
  }
  nm <- names(x)
  if(length(unique(nm)) <  length(nm)){
    warning("Deduplicating sheet names")
    names(x) <- make.unique(substring(names(x), 1, 28), sep = "_")
  }

Could be changed to:

  nm <- names(x)
  if(any(nchar(nm) > 31)){
    warning("Truncating sheet name(s) to 31 characters")
    names(x) <- substring(nm, 1, 29)
    nm <- names(x)
  }
  if(anyDuplicated(nm) != 0L){
    warning("Deduplicating sheet names")
    names(x) <- make.unique(substring(nm, 1, 28), sep = "_")
  }

but I didn't know how to (nor if I should) submit a pull request.