Hanski 连接指数的 r 函数
我必须计算我的栖息地斑块的汉斯基连接指数,但无法找到具有此功能的包。于是我自己写了一篇。我想分享它,以防它对其他人有用。这也是我从头开始编写的第一个函数,所以如果我犯了错误,请告诉我。
这是我的函数,面积 a带有各自补丁区域的向量和带有补丁间距离的dist矩阵。 Alp 和 bet 是数值常量。可以使用“metacapa”包中的函数“patch_config(x,units = c(“m”,“km”))”轻松获得面积和距离patch_config:计算块间距离和面积。
HanskiIC<-function(area, dist, alp, bet){ alphmat<-matrix(-alp,1,1)
alphdist<-dist*c(alphmat)
IC<-(exp(alphdist)%*%(area^bet))-area^bet
return(IC)}
PS:我希望我将其发布在正确的平台上,并且对其他人有用。
I had to calculate the Hanski connectivity index for my habitat patches, but was unable to find a package that had a function for this. So I wrote one myself. I wanted to share it in case it could be useful for someone else. It is also the first function i wrote from scratch, so please let me know If I made a mistake.
Formula for Hanski connectivity index
This is my function, with area a vector with the respective patch areas and dist a matrix with the interpatch distances. Alp and bet are numerical constants. Area and dist can easily be obtained with the function "patch_config(x, units = c("m", "km"))" from the package "metacapa"patch_config: Calculate interpatch distances and areas.
HanskiIC<-function(area, dist, alp, bet){ alphmat<-matrix(-alp,1,1)
alphdist<-dist*c(alphmat)
IC<-(exp(alphdist)%*%(area^bet))-area^bet
return(IC)}
ps: i hope I posted this on the right platform and it can be useful for someone else.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论