JohnsonHsieh / iNEXT

R package for interpolation and extrapolation
https://JohnsonHsieh.github.com/iNEXT
57 stars 25 forks source link

Error message using estimateD #67

Open Conny42 opened 2 years ago

Conny42 commented 2 years ago

Hi, I'm running into a weird error using function estimateD.

I'm working with a data frame having species as rows and sample sites as columns.

If I'm using the following code: dfy<-estimateD(as.data.frame(cara), datatype="abundance",base="coverage", level=0.80, conf=NULL)

The function throws this error: Error in data.frame: arguments imply differing number of rows

I checked the data frame and all columns and rows have the same lenght. There are no empty rows/columns or NAs. I managed to find the columns that cause the error and they either have only one species present or a mix of ones and twos as abundances in them....

If I delete these columns everything works fine - but I will loose almost 10 sites out of 62. There are generelly low abundances in my data set and species numbers are also quite low.

I'm not quite sure what's going on - as the error only happens if using this particular data set.

JonasGlatthorn commented 2 years ago

Hi, same here. Here is a minimum example:

library(iNEXT)
x <- list(A = c(3, 3, 2, 1), B = c(3, 3, 2, 1))
set.seed(18)
estimateD(x)

which produces the following error message:

Error in data.frame(..., check.names = FALSE) : 
  arguments imply differing number of rows: 6, 5

I think the problem is here https://github.com/JohnsonHsieh/iNEXT/blob/e31d091cb2222925593a1c21db4bdc5efed78068/R/invChat.R#L335

I don't really understand at which occasions duplicate rows in the output tmp may occur that need to be removed. In this example a row is being discarded because a diversity estimate of the two sites A and B happens to be identical coincidentially, which produces then the error later as tmp now has only 5 instead of the expected 6 rows. Whatever the purpose of removing duplicate rows originially was, currently I think it is not working properly in this example.

Thanks!

Jonas

Moose37 commented 2 years ago

Hi!

I've had the same issue. So I tried the sample code and got the exact same error.

library(iNEXT)

data(ant)

estimateD(ant,  datatype="incidence_freq",  base="coverage",   level=0.985,  conf=NULL) 

Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 3, 0 Thank you!

T

vlonde commented 2 years ago

Hi guys! I have the same problem trying to run the function estimateD. Some datasets give this error, but others do not. Any of you found a solution? Thank you. Vinícius

JonasGlatthorn commented 2 years ago

Hi, when a newer version of the package is installed from another fork of the repository (devtools::install_github('AnneChao/iNEXT')), the error does not occur any longer in my case. Jonas

vlonde commented 2 years ago

Hi Jonas, Thank you for being so helpful. Unfortunately, I'm experiencing an error and could not install the package via Anne Chao's GitHub. The error is as follows:

Warning messages: 1: In i.p(...) : installation of package ‘fansi’ had non-zero exit status 2: In i.p(...) : installation of package ‘C:/Users/VLF_C/AppData/Local/Temp/RtmpSS8afr/file2e7415312993/iNEXT_2.1.7.tar.gz’ had non-zero exit status

The error doesn't occur when installing via Johnson Hsieh's GitHub, but the function 'estimateD' still doesn't work. I emailed Dr Anne Chao and hope she will answer me. Kind regards, Vinicius

mikeroswell commented 2 years ago

I just installed the version from Anne Chao's github and still got this issue.

mikeroswell commented 2 years ago

See my writeup here: https://stackoverflow.com/a/73080729/8400969. I don't totally understand the intent behind the duplicate subsetting.

vlonde commented 2 years ago

Yeah. The problem persists. I contacted Anne Chao in January, but she (and Johnson Hsieh) ignored my email. This is the problem of "star scientists".

JohnsonHsieh commented 2 years ago

Fix from to https://github.com/JohnsonHsieh/iNEXT/pull/68