Hi Catherine,
First off — I'm not familiar with these particular packages, so I can't help you entirely there. But, I tried to replicate the issue and found this:
> obs.null.output<-cbind(dbFD(traits[colnames(my.sample),],my.sample)$FDis,replicate(9,dbfd.shuff(traits)))
Error in dbFD(traits[colnames(my.sample), ], my.sample) :
'x' must have names.
x is the first argument, and you've provided it a vector. This is a subtly of R: when accessing a single column, R will return a vector, not a dataframe of one column. You can prevent R from dropping these other dimensions by setting drop=FALSE in the bracket operator:
> dbFD(traits[colnames(my.sample),, drop=FALSE],my.sample)
FRic: Only one continuous trait or dimension in 'x'. FRic was measured as the range, NOT as the convex hull volume.
FDiv: Cannot not be computed when 'x' contains one single continuous trait or dimension.
Ok, that worked — let's make the same change to your function:
dbfd.shuff<-function(x)
{
rownames(x)<-sample(rownames(x),length(rownames(x)),replace=F)
dbFD(x[colnames(my.sample),, drop=FALSE],my.sample)$FDis
}
Now test it:
> obs.null.output<-cbind(dbFD(traits[colnames(my.sample),, drop=FALSE],my.sample)$FDis,replicate(9,dbfd.shuff(traits)))
FRic: Only one continuous trait or dimension in 'x'. FRic was measured as the range, NOT as the convex hull volume.
FDiv: Cannot not be computed when 'x' contains one single continuous trait or dimension.
FRic: Only one continuous trait or dimension in 'x'. FRic was measured as the range, NOT as the convex hull volume.
FDiv: Cannot not be computed when 'x' contains one single continuous trait or dimension.
Something's working! And this produces output (that you should check in light of all these warnings):
> obs.null.output[1:5, 1:5]
[,1] [,2] [,3] [,4] [,5]
p140 0.5186213 0.7345921 1.2245037 0.5973686 0.8279857
p190 0.6575400 0.5258475 0.5867715 0.5258377 0.5463295
p240 0.6714371 0.9018721 0.8990632 0.5508297 0.6955668
p290 0.2113815 1.1923106 0.6213570 0.5040267 0.8639043
p340 0.4941634 1.0224523 0.9082391 0.6117156 0.8981580
Hope this helps,
Vince