Reputation: 13
I am trying to run a Canonical Correspondence Analysis on diet composition data (prey.counts) with respect to a suite of environmental variables (envvar). Every row and every column sums to greater than 0, but I keep getting this error message:
diet <- cca(prey.counts, envvar$SL + envvar$Month + envvar$water.temp +
envvar$salinity + envvar$DO)
Error in if (any(rowSums(X) <= 0)) stop("All row sums must be >0 in the community data matrix") :
missing value where TRUE/FALSE needed
I have double and triple checked the prey.counts dataframe for NAs or empty columns/rows and none of them sum to zero or are missing values. R, RStudio, and all packages are fully up to date. Any help would be appreciated!
Meredith
Upvotes: 0
Views: 3755
Reputation: 174778
The problem is how you are calling the function, you seem to be mixing the default and formula interfaces (and abusing the formula notation whilst you are at it).
Does this help:
diet <- cca(prey.counts ~ SL + Month + water.temp + salinity + DO, data = envvar)
Alternatively, if the named variables are the only ones in envvar
, you could do either of
diet <- cca(prey.counts ~ ., data = envvar)
or
diet <- cca(prey.counts, envvar)
with the latter using the less flexible but simple default
method for cca()
.
Upvotes: 1