如何在 R 中为这种情况编写循环?

时间:2021-05-31 03:36:02

标签: r loops integrated

我有一个包含 121 行和 10 列的数据库。其中一列对应于 Station,另一列对应于深度,其余对应于化学变量(温度、盐度等)。我想使用函数 oce::integrateTrapezoid 按站计算这些化学性质的积分值。这是我第一次做循环,所以我不知道如何。你能帮我吗?

dA<-matrix(data=NA, nrow=121, ncol=3)
for (Station in unique(datos$Station))
{dA[Station, cd] <- integrateTrapezoid(cd, Profundidad..m., "cA")
  }
<头>
车站 深度 temp
1 10 28
1 50 25
1 100 15
1 150 10
2 9 27
2 45 24
2 98 14
2 152 11
3 11 28.7
3 48 23
3 102 14
3 148 9

0 个答案:

没有答案