相关疑难解决方法(0)

计算R data.table中前三行的总和(按网格方)

我想计算每个网格方块过去三天的降雨量,并将其添加为我的data.table中的新列.为了清楚起见,我想总结一下当前和上一天的降雨量,对于每个气象网格广场

library ( zoo )
library (data.table)


# making the data.table
rain           <- c(NA, NA, NA, 0, 0, 5, 1, 0, 3, 10)  # rainfall values to work with
square         <- c(1,1,1,1,1,1,1,1,1,2)               # the geographic grid square for the rainfall measurement
desired_result <- c(NA, NA, NA, NA, NA, 5, 6, 6, 4, NA )  # this is the result I'm looking for (the last NA as we are now on to the first day of the second grid square)
weather …
Run Code Online (Sandbox Code Playgroud)

r filter zoo data.table

4
推荐指数
2
解决办法
2022
查看次数

标签 统计

data.table ×1

filter ×1

r ×1

zoo ×1