[R-sig-eco] Negative Data Error with Decorana in Vegan

Michele Tobias tobias.michele at gmail.com
Tue Jul 20 23:37:20 CEST 2010


On 7/19/2010 5:49 PM, Gavin Simpson wrote:
> On Mon, 2010-07-19 at 17:35 -0700, Michele Tobias wrote:
>    
>> 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?
>>      
> No; decorana has a check for that:
>
> require(vegan)
> data(dune)
> dune[1,1]<- "10"
> decorana(dune)
>
>    
>> decorana(dune)
>>      
> Error in rowSums(veg) : 'x' must be numeric
>
>    
>> Any ideas what is causing the problem or how to get around it?  Thank you!
>>      
> 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:
>
>    
>> sessionInfo()
>>      
> 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.
>
>    
>> best,
>> Michele
>>      
> HTH
>
> G
>
>    
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

-- 
Michele Tobias

PhD Candidate
Geography Graduate Group
University of California, Davis

mmtobias at ucdavis.edu
http://ggg.ucdavis.edu/student/michele-m-tobias
http://ucdavis.academia.edu/MicheleTobias



More information about the R-sig-ecology mailing list