Hi All,
About "apply" function, I need your guys' help to figure out my problem.

below is my example.
> data
GMT
              A    B
2011-02-24 47.3 87.9
2011-02-25 47.4 88.1
2011-03-01 48.1 88.6

I want to do standardized process to compare both series.
Like, 
> StdTS(data[,1])
GMT
                  A
2011-02-24 100.0000
2011-02-25 100.2112
2011-03-01 101.6803
> StdTS(data[,2])
GMT
                  B
2011-02-24 100.0000
2011-02-25 100.2273
2011-03-01 100.7945


I code a function.

function(x) {


require(fBasics)


x.ret <- returns(x)


x[1] <- 100

for(i in 2:length(x)){

x[i] <- x[i-1]*(1+x.ret[i-1])
      
      }

  x

}

Individual column testing is well as above.
But, I use "apply(data,2,StdTS)" 

> apply(data,2,StdTS)
GMT
             A   B
2011-02-24 100 100
2011-02-25  NA  NA
2011-03-01  NA  NA


I don't know why ?

Anyone can help me ?

Sincerely,
Josh
	[[alternative HTML version deleted]]

