[R] cca in vegan (formula instead of community matrix data)

Gavin Simpson gavin.simpson at ucl.ac.uk
Sat Jul 17 19:42:46 CEST 2010


On Sat, 2010-07-17 at 12:44 +0800, elaine kuo wrote:
> Dear List,
> 
> I tried to do cca based on species data and environmental variables (formula
> instead of community data).
> However, there was an error saying row sums must be >0.
> I searched the previous related messages but found few solutions.
> Please kindly help and thank you in advance.

You have samples that have no species observed at all. As such is it
impossible to anything with these samples. Remove them and then fit your
model

datam <- with(datam, datam[rowSums(WinterM_ratio) > 0, ])
m.cca <- cca(WinterM_ratio ~ topo_mean + coast + prec_max +
             temp_min + evi_min,  datam)

However, I have one question for you; is WinterM_ratio a univariate
response (single column)? If it is, why do you want to analyse it using
CCA? CCA is generally used for multivariate species responses.

Finally; you might want to do something about that warning message.
Either your R is out of date or your package library is. If you are
using R2.11-x then run this:

update.packages(checkBuilt = TRUE)

to update the packages to the newest version of R; there have been lots
of changes in the way help is processed / made available that might not
be available if using packages built under earlier versions of R.

HTH

G

> 
> 
> code
> This is vegan 1.17-3
> Warning message:
> package 'vegan' was built under R version 2.10.1
> 
> rm(list=ls())
> library(vegan)
> 
> datam <-read.csv("c:/migration/M_R_20100707_winterM.csv",header=T,
> row.names=1)
> dim(datam)
> datam[1,]
> 
> m.cca  <-
>  cca(datam$WinterM_ratio~datam$topo_mean+datam$coast+datam$prec_max
> +datam$temp_min+datam$evi_min,  datam)
> 
> error in  cca.default(d$X, d$Y, d$Z) :
>   All row sums must be >0 in the community data matrix
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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