An "efficient" workaround in the user space, to handle the error "escaped" from yahooKeystats follows: -- efficient means no need to probe the website

for (ticker %in% tickers) {
        ks = tryCatch(yahooKeystats(ticker, try=FALSE), error=function(...) {return(NULL);}, finally=function(){});

        if (is.null(ks)) {
            cat(paste('No data: ', ticker, '\n\n', sep=''));
            flush.console();
            next;
        }
}


--- On Tue, 3/31/09, Yohan Chalabi <chalabi@phys.ethz.ch> wrote:

From: Yohan Chalabi <chalabi@phys.ethz.ch>
Subject: Re: [R-SIG-Finance] fImport: yahooKeystats error
To: "Andy Zhu" <andyzhu35@yahoo.com>
Cc: r-sig-finance@stat.math.ethz.ch
Date: Tuesday, March 31, 2009, 3:43 AM

>>>> "AZ" == Andy Zhu <andyzhu35@yahoo.com>
>>>> on Mon, 30 Mar 2009 20:47:29 -0700 (PDT)

   AZ> How to catch error in this function? My following code seems
   AZ> not working with this fImport:
   AZ> library(fImport);
   AZ> ticker = 'ABI';
   AZ> if (inherits(try({ks=yahooKeystats(ticker)}, silent = F),
   AZ> try-error)) {
   AZ> print('no data');
   AZ> }

Hi Andy,

I would set the argument 'try' to FALSE  in 'yahooKeystats'.
This gives with your code  :

library(fImport);
ticker = 'ABI';
if (inherits(try({ks=yahooKeystats(ticker, try=FALSE)}, silent = F), "try-error")) {
print('no data');
}

But it would be better to cast the error you mentioned inside 
'yahooKeystats'. I will have a look at it when I have some spare time.

regards,
Yohan

-- 
PhD student
Swiss Federal Institute of Technology
Zurich

www.ethz.ch



      
	[[alternative HTML version deleted]]

