如何创建一个函数或循环,该函数或循环可以从每行的另一列上方总结一定量的行
我正在尝试计算海洋中的学位加热周,并且想知道如何创建一个循环或其他一些可以计算此值并将其放入每行的新列(DHW)中的方法。 DHW是每天计算的值。
它是在另一列值(热点)的12周滚动窗口(84天)上计算出来的。 DHW是这84行的总和(在其自己的行中值(日)以及上面的83个),然后除以7
下面是我的数据框架的一个示例,我只是使用热点列来计算DHW
I am trying to calculate degree heating weeks in the Ocean and was wondering how I could create a loop or some other methods that would calculate this value and put it in a new column(DHW) for each row. DHW is a value calculated for each day.
It is calculated over a 12-week rolling window (84 days) from another column of values (hotspot). DHW is the sum of those 84 rows (value in its own row(day) plus the 83 above it) and then divided by 7
Below is an example of my data frame, I am just using the Hotspot column to calculate DHW
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确地
修复了
width = 3
towidth = 84
在2022-07-04创建的
if I understood correctly
fix
width = 3
towidth = 84
Created on 2022-07-04 by the reprex package (v2.0.1)