问题描述
我需要为我的相关随机游走创建一个边界。此边界基于我的研究区域(光栅文件)的掩码。在我的 for 循环中,我想添加一个 HttpServletRequest
循环,只要栅格的值为 0(而不是 1)就会中断。我该怎么办?我使用了 repeat{}
包。
circular
运动功能:
walk <- function(x0,y0,head0,n,parameterMu,parameterRho,parameterMean,parameterSd)
{
# Get nr of individuals,call it k
k = length(x0)
# Create list to hold data
all.paths <- list()
for (j in 1:k)
{
# Create structure to hold data
steps <- data.frame(matrix(0,6))
colnames(steps) <- c("id","x","y","steplength","heading","turningangle")
# Insert the id,starting location and heading
steps[,"id"] = j
steps[1,"x"] = x0[j]
steps[1,"y"] = y0[j]
steps[1,"heading"] = head0[j]
# Simulate steps
for(i in 2:n)
{
repeat{
# Draw step length and turning angle,compute heading
steplength = rnorm(n = 1,mean = parameterMean,sd = parameterSd)
turningangle = as.numeric(rwrappedcauchy(n = 1,mu = parameterMu,rho = parameterRho))
newbearing = as.numeric(circular(steps[i-1,"heading"]) + circular(turningangle)) %% (2*pi)
# Get new location
next.xy <- movement(x0=steps[i-1,"x"],y0=steps[i-1,"y"],step=steplength,heading=newbearing)
# Set boundary
if ??? break
}
# Store output (xy on row i,steplength/heading on row i-1)
steps[i,"x"] <- next.xy[1,"x"]
steps[i,"y"] <- next.xy[1,"y"]
steps[i,"steplength"] <- next.xy[1,"step"]
steps[i,"heading"] <- newbearing
steps[i,"turningangle"] <- turningangle
}
# Store trajectory in list
all.paths[[j]] <- steps
}
# Return output
return(all.paths)
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)