I need to calculate the sum of a constant raised to a power based upon an index. For example if my constant is a rate .5 and the index is 4, I want to sum .5^1+.5^2+.5^3+.5^4 and assign this sum to an object. So my function would initiate the following:
decay_rate = .5
index_value = 5
expsum<-function(decay_rate, index_value) {
decayVector <-rep(decay_rate,index_value)
indexp <-seq(1,index_value)
}
"I guess combine decayvector and indexp like a sumproduct except decayVector values would be exponents If there is a way to create this using Plyr or sapply etc... that would be great.