[R] Fatigued R

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Tue Feb 13 15:25:55 CET 2007


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 op 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 op stat.math.ethz.ch
[mailto:r-help-bounces op stat.math.ethz.ch] Namens Shubha Vishwanath
Karanth
Verzonden: dinsdag 13 februari 2007 14:51
Aan: Sarah Goslee; r-help op 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.Date("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.sas7bdat",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 op gmail.com] 
Sent: Tuesday, February 13, 2007 7:09 PM
To: Shubha Vishwanath Karanth
Cc: r-help op 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 op 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 op 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