-
Notifications
You must be signed in to change notification settings - Fork 10
Description
SimilarityPair is sometimes giving the error:
"Error in colSums(data) : 'x' must be an array of at least two dimensions"
apparently when calculated for assemblages with one very dominant species, and when similarity (abundance) indexes are very close to one.
By "sometimes" I mean that the first time you run the function for the data, it gives the error, but then the second/third time you re-run the same command for the exact same data the error is gone (see code below). This is problematic within a for loop, because the loop keeps crashing due to the error. And every time I run the for loop, the error happens for different data.frames (i.e., different 'i' values) - but the data.frames all share the characteristic of having one very dominant species in at least one of the two assemblages. I of course did not run the function SimilarityPair for assemblages with solely one species, all assemblages have actually at least 3 species (see example below).
Hope I explained the problem clearly and thank you for the attention.
Code:
sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X Yosemite 10.10.5
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_2.2.1 SpadeR_0.1.1 geosphere_1.5-7 reshape_0.8.7
class(sim_null_data)
[1] "data.frame"
colSums(sim_null_data)
holocene lgm
100 100
sim_null_data
holocene lgm
1 0.0 0.0
2 0.0 0.0
3 0.0 0.0
4 0.0 0.0
5 0.0 0.0
6 0.0 0.0
7 0.0 0.0
8 0.0 0.0
9 0.0 0.0
10 0.0 0.0
11 1.0 2.1
12 97.6 97.6
13 0.0 0.0
14 0.0 0.0
15 0.0 0.0
16 0.0 0.0
17 0.0 0.0
18 0.0 0.0
19 0.0 0.0
20 0.0 0.0
21 0.0 0.0
22 0.0 0.0
23 0.0 0.0
24 0.0 0.0
25 0.0 0.0
26 0.0 0.0
27 0.0 0.0
28 1.4 0.0
29 0.0 0.0
30 0.0 0.0
31 0.0 0.0
32 0.0 0.0
33 0.0 0.3
34 0.0 0.0
35 0.0 0.0
sim_null_i <- SimilarityPair(sim_null_data, datatype = c("abundance"), nboot = 10)
Error in colSums(data) : 'x' must be an array of at least two dimensions
sim_null_i <- SimilarityPair(sim_null_data, datatype = c("abundance"), nboot = 10)
class(sim_null_i)
[1] "spadeTwo"
sim_null_i
(1) BASIC DATA INFORMATION:
The loaded set includes abundance/incidence data from 2 communities
and a total of 4 species.
Samples size in Community 1 n1 = 100
Samples size in Community 2 n2 = 100
Number of observed species in Community 1 D1 = 3
Number of observed species in Community 2 D2 = 3
Number of observed shared species in two communities D12 = 2
Number of bootstrap replications for s.e. estimate 10
Some statistics:
f[11]= 0 ; f[1+]= 1 ; f[+1]= 0 ; f[2+]= 0 ; f[+2]= 0 ; f[22]= 0
(2) EMPIRICAL SIMILARITY INDICES:
Estimate s.e. 95%Lower 95%Upper
(a) Classic richness-based similarity
C02 (q=0, Sorensen) 0.6667 0.1858 0.3025 1.0309
U02 (q=0, Jaccard) 0.5000 0.2250 0.0590 0.9410
(b) Measures for comparing species relative abundances
C12=U12 (q=1, Horn) 0.9901 0.0066 0.9771 1.0000
C22 (q=2, Morisita-Horn) 0.9998 0.0007 0.9985 1.0000
U22 (q=2, Regional overlap) 0.9999 0.0004 0.9992 1.0000
ChaoJaccard-abundance 0.9831 0.0230 0.9380 1.0282
ChaoSorensen-abundance 0.9915 0.0119 0.9682 1.0148
(c) Measures for comparing size-weighted species relative abundances
Horn size-weighted (q=1) 0.9901 0.0067 0.9770 1.0000
(d) Measures for comparing species absolute abundances
C12=U12 (q=1) 0.9901 0.0067 0.9770 1.0000
C22 (Morisita-Horn) 0.9998 0.0004 0.9990 1.0000
U22 (Regional overlap) 0.9999 0.0002 0.9995 1.0000
Bray-Curtis 0.9860 0.0155 0.9556 1.0000
(3) ESTIMATED SIMILARITY INDICES:
Estimate s.e. 95%Lower 95%Upper
(a) Classic richness-based similarity:
C02 (q=0, Sorensen) 0.6667 0.1909 0.2925 1.0409
U02 (q=0, Jaccard) 0.5000 0.2295 0.0502 0.9498
(b) Measures for comparing species relative abundances
C12=U12 (q=1, Horn) 0.9916 0.0068 0.9781 1.0000
C22 (q=2, Morisita-Horn) 1.0000 0.0005 0.9989 1.0000
U22 (q=2, Regional overlap) 1.0000 0.0003 0.9995 1.0000
ChaoJaccard-abundance 0.9860 0.0228 0.9413 1.0307
ChaoSorensen-abundance 0.9930 0.0118 0.9699 1.0161
(c) Measures for comparing size-weighted species relative abundances
Horn size-weighted (q=1) 0.9916 0.0049 0.9819 1.0000
(d) Measures for comparing species absolute abundances
C12=U12 (q=1) 0.9916 0.0049 0.9819 1.0000
C22 (q=2, Morisita-Horn) 1.0000 0.0004 0.9992 1.0000
U22 (q=2, Regional overlap) 1.0000 0.0002 0.9996 1.0000
Bray-Curtis 0.9868 0.0139 0.9595 1.0000
NOTE: If an estimate is greater than 1, it is replaced by 1.