I am trying to perform Anosim {vegan} on my ecological data and I keep getting the same error message. I don't think this is a duplicate question from another one already posted and would like to fully show what's happening.
I have got my numeric dataframe ("sps") consisting of 17 rows (sites) and 313 columns (species), and a second dataframe ("env.data") containing a column with 17 factors. I would therefore want to test if there are any significant differences between my 17 groups.
Here is a sample of my data:
> sps[,2:5]
A. faranauti A. tecta A. lyra A. arbuscula
Sargasso Sea 0 0 2 0
Equatorial Brazil 0 0 0 0
Canarias Sea 0 0 0 0
Corner Seamounts 0 0 0 2
Gulf of Mexico 0 0 0 0
Labrador Sea 0 0 0 0
Equatorial Africa 0 0 0 0
Tropic Seamount 0 0 0 107
NewEngland Seamount Chain 0 0 0 0
Norwegian Basin 0 0 0 0
Eastern North Atlantic 0 0 3 0
Logachev and BritishIsles 0 0 0 4
Reykjanes Ridge 0 0 0 0
MAR North 0 0 0 14
Flemish Cap 0 0 0 217
MAR South 1 1 0 0
Azores Seamount Chain 0 0 0 12
> class(sps)
[1] "data.frame"
> head(env.data)
idcell geo_area
1 1 Sargasso Sea
2 2 Equatorial Brazil
3 3 Canarias Sea
4 4 Corner Seamounts
5 5 Gulf of Mexico
6 6 Labrador Sea
> str(env.data)
'data.frame': 17 obs. of 2 variables:
$ idcell : Factor w/ 17 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
$ geo_area: Factor w/ 17 levels "Canarias Sea",..: 15 5 1 2 7 8 4 17 12 13..
Following {vegan}, I have first calculated a dissimilarity matrix with Sorensen as the distance method. I then use this dissimilarity matrix as my input for anosim:
dist.sorensen <- vegdist(sps, method= "bray", binary = TRUE, na.rm= TRUE,
diag = TRUE)
sorensen.anosim <- anosim(dat=dist.sorensen, env.data$geo_area, permutations
= 999)
> summary(sorensen.anosim )
Call:
anosim(dat = dist.sorensen, grouping = env.data$geo_area, permutations =
999)
Dissimilarity: binary bray
ANOSIM statistic R:
Significance: 0.001
Permutation: free
Number of permutations: 999
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
'x' must be atomic
I have also tried anosim with the raw species data and I get the same error:
raw.anosim <- anosim(sps, env.data$geo_area, permutations = 999, distance =
"bray")
Any ideas? My "sps" dataframe (x) is numeric. My "env.data" dataset (groupings) has a factor column with 17 levels. I can't see where the error comes from, unless it's intrinsic to my data. Many of the 313 species listed in my original dataframe have been recorded only once across my 17 sites (very probably due to sampling bias). However, I get clusters after performing "vegdist (Sorensen index)" and "hclust".