我正在使用某人的代码来计算整个英国各地鸟类的功能分布
使用FD软件包
fd_mi <- fdisp(gd_mi, ts_mi$eco_mi)
上面是我正在使用的代码行
这是我收到的错误消息:“'d'和'a'中的种类标签必须相同,并按字母顺序排列(或简单地按相同顺序排列)”。
我想这意味着我加入的两个数据集中的物种名称不匹配,但是我已经在excel中进行了检查,看来它们确实匹配。有人可以帮忙吗?
答案 0 :(得分:1)
该函数希望您的数据显示如下:
> dummy.dist
sp1 sp2 sp3 sp4 sp5 sp6 sp7
sp2 0.2181884
sp3 0.5240052 0.6678082
sp4 0.6737443 0.5610028 0.8225701
sp5 0.5291113 0.8145699 0.4862253 0.4843264
sp6 0.6100161 0.5932587 0.2784736 0.7073925 0.6067323
sp7 0.4484235 0.6863374 0.4848663 0.5575126 0.3023416 0.6187844
sp8 0.4072834 0.2039443 0.5958904 0.2390962 0.5585525 0.4470207 0.7030186
> dummy$abun
sp1 sp2 sp3 sp4 sp5 sp6 sp7 sp8
com1 1 1 0 0 4 2 0 0
com2 0 0 0 2 1 0 0 5
com3 2 0 0 0 0 1 0 3
com4 1 0 7 0 0 0 0 0
com5 0 0 2 3 3 0 0 0
com6 0 3 0 0 5 6 1 6
com7 3 5 0 3 0 0 0 0
com8 0 0 0 0 6 2 1 2
com9 4 1 1 3 0 0 2 0
com10 0 4 1 0 0 0 6 1
# If we rearrange the columns in the abundance matrix...
shuffled <- dummy$abun[, sample(1:ncol(dummy$abun))]
> shuffled
sp4 sp8 sp3 sp2 sp1 sp6 sp5 sp7
com1 0 0 0 1 1 2 4 0
com2 2 5 0 0 0 0 1 0
com3 0 3 0 0 2 1 0 0
com4 0 0 7 0 1 0 0 0
com5 3 0 2 0 0 0 3 0
com6 0 6 0 3 0 6 5 1
com7 3 0 0 5 3 0 0 0
com8 0 2 0 0 0 2 6 1
com9 3 0 1 1 4 0 0 2
com10 0 1 1 4 0 0 0 6
#...and run the function...
ex1 <- fdisp(dummy.dist, shuffled)
# ...we get this error:
# Species labels in 'd' and 'a' need to be identical and ordered alphabetically
# (or simply in the same order).
# Assuming the number and names of species are the same,
# we can put them in the same order as the dist matrix:
shuffled[, attr(dummy.dist, 'Labels')]
# So if your issue is just the order, you might be able to solve it with:
fd_mi <- fdisp(gd_mi, ts_mi$eco_mi[, attr(gd_mi, 'Labels')])
如果这没有帮助,请按照以下方法开始对问题进行故障排除:
# These two things should be:
class(gd_mi) # should be 'dist'
class(ts_mi$eco_mi) # should be 'matrix'
# These two numbers should be the same:
attr(gd_mi, 'Size')
ncol(ts_mi$eco_mi)
# If they're not the same, this might show you which species names in gd_mi are not in ts_mi$eco_mi:
setdiff(attr(gd_mi, 'Labels'), colnames(ts_mi$eco_mi))
# If that still doesn't point to the issue, show us the output from:
str(gd_mi)
str(ts_mi$eco_mi)
免责声明:我对FD
软件包没有任何经验,但是我总是在这里尝试帮助生物学家。