[R-SIG-Finance] Filler necessary

Stampfl Bernd 0969 SPI Bernd.Stampfl at Sparinvest.com
Fri Apr 20 16:53:05 CEST 2007


I was writing a simple code to compare different Moving Averages (using
rollmean).

CODE:
**************************************************************
FX.Window.A <- 5

FX.Window.B <- 20

FX.Window.Max <- 100

 

FX.Price <- read.csv("MAFX.csv")

FX.Price <- na.omit(FX.Price[,2])

#summary(FX.Price)

 

#FX.Date <-  na.omit(FX.Price[,1])

#FX.Date

FX.Date <- "2007-01-11"

FX.Price <- zooreg(FX.Price,start=as.Date(FX.Date))

 

Mean.Result = c()

  for(i in 1:FX.Window.Max){

    FX.Window.A[i+1] <- rollmean(FX.Price,FX.Window.A[i])

    Mean.Result[i]=FX.Window.A[i+1]

}

 

Rollmean.A <- rollmean(FX.Price,FX.Window.A)

Rollmean.B <- rollmean(FX.Price,FX.Window.B)
**************************************************************

I tried to open a vector for storing the results but I got an error
message - 'cause the longer the windows the less results you get. 

Do you know some ways to fill the missing data?

Hope you can help me guys. I just switched to R and therefore a
semi-novice.

Thanks a lot.

Bern



More information about the R-SIG-Finance mailing list