[R] problem with data for metaMDS analysis please help

Gavin Simpson gavin.simpson at ucl.ac.uk
Wed Apr 23 09:55:37 CEST 2008


On Tue, 2008-04-22 at 20:19 -0400, stephen sefick wrote:
> am at my wit's end.  I am not sure what is wrong with this data matrix.  It
> is sparse because it is a matrix of species, but I have looked at the row
> totals and column totals and they are positive.
> rmetaMDS(x.d)
> Error in if (autotransform && xam > 50) { :
> missing value where TRUE/FALSE needed
> What is wrong?  And in the future how in God's name do I easily diagnose
> whatever problem there is with this data.  I am in debt to anyone who
> figures this one out.

[All this presumes that x.d is your data as in the file you attached.
You could have helped by including the few lines to read in the data and
do the metaMDS so I didn't have to work this out and guess what x.d
was.]

The problem is very simple; you don't have *all* positive marginal
totals with the dataset you attached. Two variables have missing values
in the R sense, and unless you ask for R to remove missing values (which
in this case would defeat the object of checking the marginal totals),
you can't have found all positive values using the common R tools for
marginal totals.

Take a closer look at your data (that you attached). There are two
columns with NA in them.

This is how I diagnosed the problem:

> # read in the data
> dat <- read.delim("trans.txt")
> # generate species sums these will be NA is any are missing
> csum <- colSums(dat)
> # check if any are missing
> any(is.na(csum))
[1] TRUE
> # yes, some missing, so which ones?
> which(is.na(csum))
X49 X68 
 49  67 
> # Check how many are missing
> summary(dat[, c("X49","X68")])
      X49              X68         
 Min.   :  0.00   Min.   :0.00000  
 1st Qu.:  0.00   1st Qu.:0.00000  
 Median :  1.00   Median :0.00000  
 Mean   :  9.13   Mean   :0.02094  
 3rd Qu.:  6.00   3rd Qu.:0.00000  
 Max.   :257.00   Max.   :2.00000  
 NA's   :  1.00   NA's   :1.00000

These are rudimentary data management and checking steps in R. It would
be worth brushing up on these sorts of things in one of the online
documents. Alternatively, you could have included what you did that lead
you to believe that you had all positive marginal totals so we could see
where you went wrong.

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list