[R] Try Giving Invalid Argument Type Error

Sparks, John James jspark4 at uic.edu
Sat May 19 23:00:03 CEST 2012


Dear R Helpers,

I am getting an error message from the try function that I don't
understand so I am hoping that someone can help.

I am scraping from web pages, but sometimes they disappear.  When that
happens I need to control for it with some sort of function.

This web page is parsed without a problem.


exh<-"NASDAQ"
tic<-"EGHT"
URL<-paste("http://www.advfn.com/p.php?pid=financials&btn=istart_date&mode=quarterly_reports&symbol=",
exh,"%3A",tic,"&istart_date=0", sep = "")
doc <- htmlParse(URL)

However, when I change the value of tic it will not.

tic<-"AACOU"
URL<-paste("http://www.advfn.com/p.php?pid=financials&btn=istart_date&mode=quarterly_reports&symbol=",
exh,"%3A",tic,"&istart_date=0", sep = "")
doc <- htmlParse(URL)
Error in htmlParse(URL) :
  error in creating parser for
http://www.advfn.com/p.php?pid=financials&btn=istart_date&mode=quarterly_reports&symbol=NASDAQ0X1.CP-1072AACOU&istart_date=0

I tried to account for this using the try function but I get the error
below that I don't understand.


options(error = expression(NULL))
URL<-paste("http://www.advfn.com/p.php?pid=financials&btn=istart_date&mode=quarterly_reports&symbol=",
exh,"%3A",tic,"&istart_date=0", sep = "")
if(
!is(
try(
doc <- htmlParse(URL)
,"try-error")
)
)

{
qtrstop <- xpathApply(doc, "count(//select/option)")-5
}
Error in !silent : invalid argument type


Any help would be most appreciated.

--John Sparks



More information about the R-help mailing list