Skip to content

Commit

Permalink
Shorten URL creation
Browse files Browse the repository at this point in the history
The necessary URL can be created with one paste0() call, without
having much impact on readability, etc. Also remove the utils:: from
download.file(), since the function is already imported.
  • Loading branch information
joshuaulrich committed Oct 1, 2017
1 parent fa003f1 commit 4b3d495
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions R/getSymbols.R
Original file line number Diff line number Diff line change
Expand Up @@ -1309,16 +1309,14 @@ getSymbols.av <- function(Symbols, env, api.key,

if (verbose) cat("loading", sym.name, ".....")

url.params <- paste(paste0("function=", FUNCTION),
paste0("symbol=", sym.name),
paste0("interval=", interval),
paste0("outputsize=", output.size),
paste0("apikey=", api.key),
sep="&" )
url <- paste0("http://www.alphavantage.co/query",
"?", url.params )
URL <- paste0("http://www.alphavantage.co/query",
"?function=", FUNCTION,
"&symbol=", sym.name,
"&interval=", interval,
"&outputsize=", output.size,
"&apikey=", api.key)

utils::download.file(url=url, destfile=tmp, quiet=!verbose)
download.file(url=URL, destfile=tmp, quiet=!verbose)
lst <- jsonlite::fromJSON(tmp)

#
Expand Down

0 comments on commit 4b3d495

Please sign in to comment.