Skip to content

Commit

Permalink
Error if 'yahooj' symbol has no data
Browse files Browse the repository at this point in the history
The while() loop never terminates if there is no table matching the
xpath used to create 'rows'. Break if there is less than one row, and
then throw an error.

Fixes #63.
  • Loading branch information
joshuaulrich committed Apr 11, 2018
1 parent 2fbe85e commit 5802644
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/getSymbols.R
Original file line number Diff line number Diff line change
Expand Up @@ -499,13 +499,17 @@ function(Symbols,env,return.class='xts',index.class="Date",

fdoc <- XML::htmlParse(tmp)
rows <- XML::xpathApply(fdoc, "//table[@class='boardFin yjSt marB6']//tr")
if (length(rows) == 1) break
if (length(rows) <= 1) break

totalrows <- c(totalrows, rows)
page <- page + 1
}
if(verbose) cat("done.\n")

if (is.null(rows)) {
stop("No historical data for ", dQuote(Symbols[[i]]), ".")
}

# Available columns
cols <- c('Open','High','Low','Close','Volume','Adjusted')

Expand Down

0 comments on commit 5802644

Please sign in to comment.