【发布时间】:2021-06-17 10:35:43
【问题描述】:
我正在尝试使用 tidyverse 累加函数来计算两个几何级数。
这个几何级数的结果应该是 1871.445
我尝试使用以下代码行,得到答案 1200
sum(accumulate(seq(from=0, to=4, by=1/12), .init = 400, ~ .x/(1 + 0.5)))
我也在尝试计算这个几何级数:
这应该给出 4.678613 的结果,但我的代码行给了我 3
sum(accumulate(seq(from=0, to=4, by=1/12), .init = 1, ~ .x*(1/(1 + 0.5))))
【问题讨论】:
标签: r tidyverse accumulate