|
Dear S-PLUS users:
I want to make a script that calculates
returns among variables in a column vector. Specifically, I need a script that
calculates, ln(x[,i+1]/x[,i]) for all elements in a column vector x. Here,
i denotes ith row. For this purpose, I wrote the following "script" but it does
not work. It will be of great help if you could give me some advice, suggestion,
correction.
calcLN <-
function(x) { x1<-c(matrix(unlist(x),nrow=nrow(x))) x1<-log(numeric(x1)) for(i
in
1:nrow(x1)-1) { x1rtn[i]<-x1[i+1]-x1[i] i<-i+1 } x1rtn }
Regards,
Moto
|