I want to perform a rda in R, using vegan.
My code looks like this:
species<- read.delim("springspecies1.txt", header=T)
envdata<- read.delim("springenv1.txt", header=T)
RDA <- rda(species~Temperature + Salinity + O2 + Phosphate + Nitrate + Silica, envdata, scale=T, na.action=na.omit)
and I get the error message:
Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric
when I check my data I get:
sapply(species, mode)
Station Year Month S.marinoi C.tripos
"numeric" "numeric" "numeric" "numeric" "numeric"
P.alata P.seriata R.setigera C.pelagica D.confervacea
"numeric" "numeric" "numeric" "numeric" "numeric"
C.decipiens P.farcimen C.furca
"numeric" "numeric" "numeric"
There are no NA or blanks in my data set. But it seems that the species data set is the problem. I compiled a new data set with the species, but I get the same problem again. Any ideas?
The colMeans() function in R can be used to calculate the mean of several columns of a matrix or data frame in R.
Instead of using 'mode', you should be testing with 'class'. You probably have a factor column. They are of mode numeric but test FALSE with 'is.numeric'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With