[R] Loop and cbind

john seers (IFR) john.seers at bbsrc.ac.uk
Wed Jul 4 15:18:50 CEST 2007




Hi 

In what way does it not work?

My guess is that you have not declared your values outside the for loop.
As they are local they will be lost on exit.

You need to declare them before:

ewma<-vector(length=12)
standard<-vector(length=12)

for ... {
	....
}

John Seers
 


 
---

Hi, I would like to apply the following function for i between 1 and 12,
and then construct a list of the return series.

for (i in 1:12){
ewma[i] <- emaTA(calm[[i]]^2,0.03)
standard[i]<- calm[[i]]/sqrt(ewma[i])
standard <- cbind(standard[i])
}

But it does not work. Could anyone give me some advice how can I achieve
this? Many thanks
--
View this message in context:
http://www.nabble.com/Loop-and-cbind-tf4024291.html#a11430500
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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