0

Running an analysis in RStudio, R version 3.0.1, Ubuntu 12.04. I am correlating environmental factors (envW) to an analysis (MDSnsj) using the function envfit from the vegan package 2.0-8. My environmental dataset (envW) has many missing values. I get the following error message when I run this simple command. I have tried putting text 'NA' in the missing spots but I get the same error message.

envfit(MDSnsj, envW, perm=999, na.rm=TRUE)->MDSnsef
>Error in if (any(x < 0, na.rm = na.rm)) { : 
  missing value where TRUE/FALSE needed

Can anyone explain to me what the error message means? AND .... Does anyone have any ideas how I can fix this? Thank you in advance

a guess at what is requested

traceback()
MDSnsef<-envfit(MDSnsj, envW, perm=999, na.rm=TRUE)
debugging in: envfit(MDSnsj, envW, perm = 999, na.rm = TRUE)
debug: {
UseMethod("envfit")
}

  • 3
    We need the data you ran the command with. Or a toy example that can reproduce this error. Thanks. – Simon O'Hanlon Jul 25 '13 at 09:08
  • 1
    The error message means that in the `if` condition there are no values of `x` that are not `NA`. I don't know anything about `envfit`, but possibly there are "groups" in your data that consist entirely of `NA` values. Maybe you can exclude these "groups" from analysis. – Roland Jul 25 '13 at 09:21
  • Btw, the version number of RStudio (the IDE) is not often relevant. The version numbers of R and of the package could be more interesting. – Roland Jul 25 '13 at 09:28
  • The model-fitting function `envfit` is basically choking somewhere. It could be because you have NAs in your data, or not. Just because the error message mentions missing values doesn't mean these things are necessarily related. – Hong Ooi Jul 25 '13 at 09:59
  • The output from `traceback()` would also be useful. – Richie Cotton Jul 25 '13 at 12:13
  • not a great way to solve but when I attempted to reproduce error with smaller envW dataset it didn't always error out.....I was able then to narrow th ecause down to a few columns of data. i removed them as non-esential and th eerror did not reoccur – Razz Rakali Jul 25 '13 at 17:11
  • thank you for all help, i still learnt many things, especially correct language and trouble shooting – Razz Rakali Jul 25 '13 at 17:12
  • You need to run `MDSnsef <- envfit(MDSnsj, envW, perm=999, na.rm=TRUE)` *and then* as soon as you get the **error**, run `traceback()`. Copy what it printed and add it to your question. Note that `envfit` has argument `na.rm = FALSE` and hence it would have bailed out already with an informative error message if `NA`s were an issue (or at least that is how it is intended). To debug, you need `debugonce(vegan:::envfit.default)` as the method doing the work in this case is not exported from the NAMESPACE. – Gavin Simpson Jul 25 '13 at 21:53

0 Answers0