Displaying 1 result from an estimated 1 matches for "curramorts".
2012 Jun 15
1
Divide all rows of a data frame by the first row.
..., 0, 0.0357142857142857, 0, 0, 0, 0, 0.0333,
0, 0, 0.0333, 0, 0, 0.0357142857142857, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0.0333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0), .Dim = c(10L, 19L))
prevAm<-c(0, 0, 0, 0.0666, 0, 0.0666, 0.0666, 0, 0, 0)
calcAmorts<-function(prevAmort, currAmorts, dates) {
yrs<-year(as.Date(dates))
currAmorts<-data.frame(yrs,t(currAmorts))
amortsByYears<-aggregate(x = currAmorts, by = list(yrs), FUN = "sum")[,-c(1,2)]
amortsByYears<-rbind(prevAmort, amortsByYears)
amortsByYears<-(1-apply(amortsByYears, 2, cumsum))[-1,...