I created a dataframe:
totalDeposit <- cumsum(testd$TermDepositAMT[s1$ix])
which is basically calculating cumulative sum of TermDeposit
It's pretty clear that testd is a dataframe or a list since you didn't get an error from testd$. If you had a testd in which the first element were a number but it was longer than one element you would only have gotten a warning. You perhaps wanted to write:
avgDeposit <- totalDeposit / 1:nrow(testd)
... although I admit that doesn't seem very useful. At least it won't throw an error.