R Error: “In numerical expression has 19 elements: only the first used”

后端 未结 2 1262
盖世英雄少女心
盖世英雄少女心 2021-01-18 21:34

I created a dataframe:

totalDeposit <- cumsum(testd$TermDepositAMT[s1$ix])

which is basically calculating cumulative sum of TermDeposit

2条回答
  •  迷失自我
    2021-01-18 22:17

    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.

提交回复
热议问题