Open PeterSoroye opened 8 years ago
I have the same error. Is there any solution?
Thank you very much!
Daniela
Hello Daniela,
Not sure if this will help, but I found that there was a quirk with the SortDataFun and proposed a solution in another feed:
"Further problems with ChaoShared"
The problem seems to stem from "SortDataFun"
specifically this line of code
sit1 <- sample(sit1[1:(D1-D12)], replace=F)
When the result of D1-D12 is 1, it gives three numbers (a known problem/result of doing this with a single value) rather than the result of "3".
try it:
x1 = c(1,0,1,0), x2 = c(1,1,0,1)
sit1 <- order(x1 > 0 & x2 == 0, decreasing=T)
set.seed(123)
sit1 <- sample(sit1[1:(D1-D12)], replace=F) # random sample
special1 <- cbind(x1[sit1[1:(D1-D12)]], x2[sit1[1:(D1-D12)]])
the result for special one is "1,1" and not "1,0" as it should be.
a quick fix would be an if/else on the value of D1-D12 (and I suppose for D2-D12 for sit2). e.g.
if (D1-D12 == 1){
special1 <- cbind(x1[sit1[1]], x2[sit1[1]])
} else {
set.seed(123)
sit1 <- sample(sit1[1:(D1-D12)], replace=F) # random sample
special1 <- cbind(x1[sit1[1:(D1-D12)]], x2[sit1[1:(D1-D12)]])
}
i have this error can anybody help me. if(LCL[i] == 0){Pin1 <- sum(dbinom(LCL[i]:UCL, n, P1, FALSE))} Error in if (LCL[i] == 0) { : missing value where TRUE/FALSE needed
> ParkDatasetPivot2
SL001 SL002 SL003 SL005 SL006 SL007 SL008 SL009 SL010 SL012 SL013
AMCR 1 0 0 0 0 0 0 0 0 0 0
AMRE 0 1 0 0 0 0 0 0 0 0 0
AMRO 0 1 0 0 0 0 0 0 0 0 0
BAWW 0 0 0 0 1 0 0 1 0 1 0
BGGN 1 1 1 1 1 1 1 1 1 1 1
BHCO 0 0 1 1 1 1 1 1 1 1 0
BHVI 0 0 0 0 0 0 1 0 0 0 0
BLGR 0 1 0 0 0 0 0 0 0 0 0
BLJA 1 1 1 1 1 1 1 1 1 1 1
BRTH 0 0 0 0 1 0 0 1 0 1 0
BTGR 0 0 0 0 0 0 0 0 0 0 1
CACH 1 1 1 1 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0 0 0
YTWA 1 1 1 1 1 1 1 1 1 1 1
> #Calculate iChao2 Species Richness Estimators:
> ChaoSpecies(ParkDatasetPivot2, datatype=c("incidence_raw"), k=100, conf=0.95)
Error in if (var_iChao2 > 0) { : missing value where TRUE/FALSE needed
Has there ever been a fix made for this error? I can't figure out what is causing it. My datasets for other sampling areas work fine with the same code, but this particular dataset throws this error code.
Hello Anne,
I'm attempting to run the ChaoSpecies function (method=incidence, k=10, conf=0.95) for about 360 quadrats (each in a different column) for which I have a variable number of sampling units and a possible 271 species (two example quadrats are included in the attached text file). I have a script which goes through each quadrat (column), determines whether the proportion of singleton species is greater than 0.5 (in which case it would be inappropriate to resample), and then performs the ChaoSpecies function on the quadrat and extracts certain species richness estimates to a final table.
The script works fine for most quadrats (ex. it works fine for the first example quadrat, Q22), however when it gets to certain quadrats (ex. the second example quadrat, Q23), it stops the loop and returns the following error:
And the traceback function traces the error to
Like I mentioned, it's only an issue for certain, specific quadrats, and the problematic quadrats don't seem to be obviously different from others in terms of observed species richness, sampling units or proportion of singletons. That said my knowledge on exactly how the ChaoSpecies function works, and therefore it's limitations/requirements is not comprehensive, so I though I'd ask whether you know any reason that the ChaoSpecies function might be returning this error for some quadrats?
Thanks in advance, I'd really appreciate any help or insight into this problem that you could offer.
Sincerely,
-Peter quad22and23.txt