Skip to content

Negative Data Error with Decorana in Vegan

4 messages · Michele Tobias, Gavin Simpson, Jari Oksanen

#
I'm fairly inexperienced with the Vegan package, so my apologies if I'm 
asking a very basic question.  I'm trying to use the decorana function 
in the Vegan package.  My data is all positive numbers but I get an 
error that says this:

Error in decorana(dataord) :
   'decorana' cannot handle negative data entries

The data (dataord) is of class data.frame and originated from an SQLite 
database brought into R using the RSQLite package, just in case those 
details matter.  I'm fairly sure that the numbers in the data frame are 
numbers and not text, but if they were text, would that cause the error?

Any ideas what is causing the problem or how to get around it?  Thank you!

best,
Michele
#
On Mon, 2010-07-19 at 17:35 -0700, Michele Tobias wrote:
No; decorana has a check for that:

require(vegan)
data(dune)
dune[1,1] <- "10"
decorana(dune)
Error in rowSums(veg) : 'x' must be numeric
Yes; some of your data takes values less than 0 :-)
You might think the data are all positive, but I'm certain R doesn't
think so *after* it has been processed to a matrix within decorana.

Unless you provide evidence to the contrary (such as a reproducible
example, your data, or summary output from your data) then sort your
data out so that it doesn't contain negative values.

To help further, post the output of the following:

str(dataord)
sapply(dataord, range)
apply(as.matrix(dataord), 2, range)
which(dataord < 0)

As that is likely to point to the problem. Hopefully at that point
you'll see where the problem with your data is and can sort it out
yourself. If not, post the output from the above to the list and I'll
take a closer look for you.

Also, please post details of your session info:

sessionInfo()

The above examples were with:
R version 2.11.1 Patched (2010-07-18 r52561) 
i686-pc-linux-gnu 

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=C              LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] vegan_1.17-2

loaded via a namespace (and not attached):
[1] tools_2.11.1

Note my vegan installation on my laptop is not quite up-to-date (1.17-3
is current) but there were no changes to decorana between my version and
the one on CRAN.
HTH

G
#
On 7/19/2010 5:49 PM, Gavin Simpson wrote:
Thank you for your help, Gavin!  Your suggestions helped me finally 
figure out what the problem was.  It turns out that my data frame had 
the plot names (text) in the first column instead of plot names as the 
row names for the data frame, so the error message didn't quite match 
the problem: text where it shouldn't have been and not negative data.

best,
Michele
#
On 21/07/10 00:37 AM, "Michele Tobias" <tobias.michele at gmail.com> wrote:

            
Michele,

I'm sure that there also were negative data entries because they were found
and reported. However, I changed the order of tests in the devel version of
vegan so that non-numeric data are detected and reported before checking
negative data entries.

This does not stop this kind of reports (and this was not the first one).
When R says that you have non-numeric or negative data while you are "fairly
sure" that you don't have them, the common rule is that you're wrong and R
is right. Check your data to see that it is like you expect it to be. This
is not an issue to argue with computers: they always win.

Cheers, Jari Oksanen