-3

I'm currently trying to run the SIMPER {vegan} function to a matrix that has NAs in it and currently can not be turn into 0s.

I'm getting:

Error in seq_len(min(which(z >= 0.7))) : 
argument must be coercible to non-negative integer
In addition: Warning message:
In min(which(z >= 0.7)) : no non-missing arguments to min; returning Inf

Is there a way to do it or I have to transform the data?

Thanks, Pedro L.

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
  • Post your matrix or a reproducible example. We cannot know for sure what problem you are running in to without having knowledge of your data matrix. – nadizan Jan 23 '17 at 10:03

1 Answers1

1

I think I solved your problem, although read the FAQ of how to post reproducible questions.

The problem you have is basically that nothing in your data, z, is fulfilling ">= 0.7" , therefore you are returned with integer(0). That is basically what the error message: "In min(which(tg >= 0.7)) : no non-missing arguments to min; returning Inf" refers to.

The first error message is due to you trying to calculate: "seq_len(integer(0))" which returns: "Error in seq_len(min(which(tg >= 0.7))) : argument must be coercible to non-negative integer".

Reproducible data:

tg<-matrix(data=seq(0.01,0.25,0.01),5,5)
seq_len(min(which(tg>=0.7)))

So the solution is: check your matrix "z" and the results from it by dividing the expression seq_len(min(which(tg>=0.7))) in different parts. First run which(tg>=0.7) , then min(which(tg>=0.7)) and so on. This is useful for troubleshooting codes in general.

Good luck!

nadizan
  • 1,323
  • 10
  • 23