vegan package cca error: rowsum(X) must be >0: missing value where TRUE/FALSE needed

StackOverflow https://stackoverflow.com/questions/21742245

  •  10-10-2022
  •  | 
  •  

문제

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

도움이 되었습니까?

해결책

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().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top