Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用r中的循环函数计算每天的常量值?_R - Fatal编程技术网

使用r中的循环函数计算每天的常量值?

使用r中的循环函数计算每天的常量值?,r,R,Hi有速度(val)和深度(dep)数据。所以,使用r中的循环函数,我想找到一个称为“K”(K=ODobbins(val,dep),“ODobbins”是stream新陈代谢package)中的一个函数,用于接收数据时的无限日期 structure(list(date = c("12/01/2019", "13/01/2019", "14/01/2019", "15/01/2019", "16/01/20

Hi有速度(val)和深度(dep)数据。所以,使用r中的循环函数,我想找到一个称为“K”(K=ODobbins(val,dep),“ODobbins”是
stream新陈代谢
package)中的一个函数,用于接收数据时的无限日期

structure(list(date = c("12/01/2019", "13/01/2019", "14/01/2019", 
"15/01/2019", "16/01/2019", "17/01/2019"), vel = c(0.6, 0.5, 
0.6, 0.2, 0.8, 0.1), dep = c(0.42, 0.21, 0.35, 0.24, 0.65, 0.12
)), class = "data.frame", row.names = c(NA, -6L))

有人能帮忙吗?

ODobbins是一个矢量化函数,如下所示

library(StreamMetabolism)
ODobbins
function (vel, dep) 
{
    (3.93 * (vel^0.5))/(dep^1.5)
}
在这里,
/
^
是矢量化的,因此我们可以将参数作为列传递给apply函数

with(df, ODobbins(vel, dep))
#[1] 11.183925 28.876770 14.701651 14.948261  6.707605 29.896523

您必须调用函数。
ODobbins(df$vel,df$dep)