Skip to content

Instantly share code, notes, and snippets.

@neilfws
Created October 4, 2017 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilfws/b5570f577e943bd03cdc2c171937e11f to your computer and use it in GitHub Desktop.
Save neilfws/b5570f577e943bd03cdc2c171937e11f to your computer and use it in GitHub Desktop.
# taken from the fifer package
# https://github.com/dustinfife/fifer
excelCols <- function (n)
{
vec1 = LETTERS
if (n <= 26) {
res = vec1[seq_len(n)]
}
else if (n > 26 & n <= 702) {
res = c(vec1, apply(expand.grid(vec1, vec1)[, 2:1],
1, paste, collapse = ""))[1:n]
}
else if (n > 702 & n <= 18278) {
res = c(vec1, apply(expand.grid(vec1, vec1)[, 2:1],
1, paste, collapse = ""), apply(expand.grid(vec1,
vec1, vec1)[, 3:1], 1, paste, collapse = ""))[1:n]
}
else {
res = NA
}
res
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment