Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposed symbol list utility function #320

Open
ethanbsmith opened this issue Dec 4, 2020 · 1 comment
Open

proposed symbol list utility function #320

ethanbsmith opened this issue Dec 4, 2020 · 1 comment

Comments

@ethanbsmith
Copy link
Contributor

Description

symbol cleanup utility function i use. i can turn this into a pr if you think its worth moving into quantmod

cleanSymbolList <- function(Symbols, to.upper = F, filter.na = T) {
  importDefaults("cleanSymbolList")
  if (is.null(Symbols)) return(NULL)
  if (length(Symbols) == 0) return(character())
  
  if (is.list(Symbols)) Symbols <- unlist(Symbols)
  if (!is.character(Symbols)) stop( "cleanSymbolList only accepts chracter input")
  
  Symbols <- unique(trimws(unlist(strsplit(Symbols, ";"))))
  
  if (to.upper) Symbols <- toupper(Symbols)
  if (filter.na) Symbols <- Symbols[!is.na(Symbols)]
  return(Symbols)
}
@joshuaulrich
Copy link
Owner

Thanks for the proposal. Can you explain the purpose of the function, to make sure I understand what it's doing? That will help me decide whether it's worth moving into quantmod.

A couple thoughts:

  1. I would change filter.na to na.rm to be consistent with other R functions.
  2. I would set Symbols = NULL in the argument list. Otherwise I'm not sure the is.null(Symbols) will work if Symbols is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants