Eric

Your problem lies in the way cumprod deals with NAs

If you look at ?cumprod you will see 
"An NA value in x causes the corresponding and following elements of the
return value to be NA"

Not sure what behaviour you want to see on encountering an NA (ignore it,
restart the cumprod process, .....). Making things easy for myself (it's
late), if you wish to simply ignore an NA the following would work

# sample data
y2=c(NA,1,2,3,4,5)

# ignore NA
ave(y2,is.na(y2),FUN=cumprod)

HTH

Pete

 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-do-I-fix-this-tp3239239p3241432.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org 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.

Reply via email to