[R] Fatigued R

davidr at rhotrading.com davidr at rhotrading.com
Tue Feb 13 20:11:42 CET 2007


I can't be sure what is happening to Shubhak, but I know that
the Bloomberg server bbcomm.exe throws unhandled exceptions in a 
unreproducable and uncatchable way, somewhere in their tcp code. 

It is one of the big frustrations for me in my work. 

Shubhak, I think you will just have to look carefully at what is
returned,
as Bogdan suggested in general, and take action based on that. It may be

that try[Catch] will catch some problems, but other times, you will just
get 
something that is not right, but you can tell since it has the wrong 
structure.
The bbcomm.exe essentially crashes and gets restarted automatically, so
the 
next time you try to get something, it works; so sleeping after an error
is 
a good idea.

HTH,
David

David L. Reiner
Rho Trading Securities, LLC
Chicago  IL  60605
312-362-4963

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of bogdan romocea
Sent: Tuesday, February 13, 2007 10:49 AM
To: shubhak at ambaresearch.com
Cc: r-help
Subject: Re: [R] Fatigued R

The problem with your code is that it doesn't check for errors. See
?try, ?tryCatch. For example:

my.download <- function(forloop) {
  notok <- vector()
  for (i in forloop) {
    cdaily <- try(blpGetData(...))
    if (class(cdaily) == "try-error") {
      notok <- c(notok, i)
    } else {
      #proceed as usual
    }
  }
  notok
}

forloop <- 1:x
repeat {
  ddata <- my.download(forloop)
  forloop <- ddata
  if (length(forloop) == 0) break  #no download errors; stop
}


> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Shubha
> Vishwanath Karanth
> Sent: Tuesday, February 13, 2007 10:06 AM
> To: ONKELINX, Thierry; r-help at stat.math.ethz.ch;
> sarah.goslee at gmail.com
> Subject: Re: [R] Fatigued R
>
> Hi all, thanks for your reply....
>
> But I have to make one thing clear that there are no errors in
> programming...I assure that to you, because I have extracted the data
> many times from the same program...
>
> The problem is with the connection of R with Bloomberg, sometimes the
> data is not fetched at all and so I get the below errors...It
> is mainly
> due to some network jam problems and all...
>
> Could anyone suggest me how to refresh R, or how to always make sure
> that the data is downloaded without any errors for each loop? I tried
> with Sys.sleep() to give some free time to R...but it is not
> successful
> always...
>
> Could anybody help me out?
>
> Thank you,
> Shubha
>
> -----Original Message-----
> From: ONKELINX, Thierry [mailto:Thierry.ONKELINX at inbo.be]
> Sent: Tuesday, February 13, 2007 7:56 PM
> To: Shubha Vishwanath Karanth; r-help at stat.math.ethz.ch
> Subject: RE: [R] Fatigued R
>
> Dear Shubha,
>
> The error message tells you that the error occurs in the line:
> 	merge(d_mer,cdaily)
> And the problem is that d_mer and cdaily have a different class. It
> looks as you need to convert cdaily to the correct class
> (same class as
> d_mer).
> Don't forget to use traceback() when debugging your program.
>
> You code could use some tweaking. Don't be afraid to add spaces and
> indentation. That will make you code a lot more readable.
> I noticed that you have defined some variables within your function
> (lent, t). This might lead to strange behaviour of your
> function, as it
> will use the global variables. Giving a variable the same name as a
> function (t) is confusing. t[2] and t(2) look very similar but do
> something very different.
> Sometimes it pays off to covert for-loop in apply-type functions.
>
> Cheers,
>
> Thierry
> --------------------------------------------------------------
> ----------
> ----
>
> ir. Thierry Onkelinx
>
> Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature
> and Forest
>
> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
> methodology and quality assurance
>
> Gaverstraat 4
>
> 9500 Geraardsbergen
>
> Belgium
>
> tel. + 32 54/436 185
>
> Thierry.Onkelinx at inbo.be
>
> www.inbo.be
>
>
>
> Do not put your faith in what statistics say until you have carefully
> considered what they do not say.  ~William W. Watt
>
> A statistical analysis, properly conducted, is a delicate
> dissection of
> uncertainties, a surgery of suppositions. ~M.J.Moroney
>
>
> -----Oorspronkelijk bericht-----
> Van: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] Namens Shubha Vishwanath
> Karanth
> Verzonden: dinsdag 13 februari 2007 14:51
> Aan: Sarah Goslee; r-help at stat.math.ethz.ch
> Onderwerp: Re: [R] Fatigued R
>
> Ohkkk....I will try to do that now....
>
> This is my download function...
>
>
> download<-function(fil)
> {
> con<-blpConnect(show.days=show_day, na.action=na_action,
> periodicity=periodicity)
> for(i in 1:lent)
> {
> Sys.sleep(3)
> cdaily<-blpGetData(con,unique(t[,i]),fil,start=as.chron(as.Dat
e("1/1/199
> 6", "%m/%d/%Y")),end=as.chron(as.Date("12/28/2006", "%m/%d/%Y")))
> #Sys.sleep(3)
> if(!exists("d_mer")) d_mer=cdaily else d_mer=merge(d_mer,cdaily)
> rm(cdaily)
> }
> dat<-data.frame(Date=index(d_mer),d_mer)
> dat$ABCDEFG=NULL
> path1<-paste("D:\\SAS\\Project2\\Daily\\",fil,"_root.sas7bdat",sep="")
> path2<-paste("D:\\SAS\\Project2\\Daily\\CODEFILES\\",fil,".sas
> ",sep="")
> sasname<-paste(x1,fil,"'",sep="")
> write.foreign(dat,path1,path2,package="SAS",dataname=sasname)
> blpDisconnect(con)
> }
>
> for(j in 1:lenf)
> {
> fname<-paste("D:\\SAS\\Project2\\Daily\\",filename[j],"_root.s
as7bdat",s
> ep="")
> Sys.sleep(600)
> if(!file.exists(fname)) download(fil=filename[j])
> }
>
> And lent=58 and lenf=8... 8 text files will be generated in
> this process
> if the program would have run properly, and each would be of
> size 4,000
> KB.
>
> The error message I get if the program is not run is:
>
> Error in dimnames(x) <- dn : length of 'dimnames' [2] not
> equal to array
> extent
> In addition: Warning message:
> Index vectors are of different classes: chron chron dates in:
> merge(d_mer,cdaily)
>
>
>
> Please could any one help on this?
>
> -----Original Message-----
> From: Sarah Goslee [mailto:sarah.goslee at gmail.com]
> Sent: Tuesday, February 13, 2007 7:09 PM
> To: Shubha Vishwanath Karanth
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] Fatigued R
>
> Hi Shubha,
>
> Perhaps you haven't gotten any help because you haven't provided a
> reproducible example, or even told us what you are trying to do
> (specifically)
> or what errors you are receiving. Frankly, your problem statement
> doesn't
> make any sense to me, and I can't provide advice without more
> information.
>
> As the footer of every email says:
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> Sarah
>
> On 2/13/07, Shubha Vishwanath Karanth
> <shubhak at ambaresearch.com> wrote:
> > Hi R,
> >
> >
> >
> > Please solve my problem...........
> >
> >
> >
> > I am extracting Bloomberg data from R, in a loop. R is getting
> fatigued
> > by doing this process and gives some errors. I introduced sleep
> > function. Doing this sometimes I get the results and
> sometimes not. I
> > even noticed that if I give complete rest for R (don't open
> R window)
> > for 1 day and then run my code with the sleep function, then the
> program
> > works. But if I keep on doing this with on R, repeatedly I
> get errors.
> >
> >
> >
> > Please can anyone do something for this? Is there any function of
> > refreshing R completely.....Or any other techniques?...I am really
> > getting bugged with this.......
> >
> >
> >
> > Thanks,
> >
> > Shubha
>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list