14

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?

zx8754
  • 52,746
  • 12
  • 114
  • 209
user3420443
  • 297
  • 2
  • 3
  • 8

1 Answers1

14

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'.

IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • Userul answers are supposed to be upvoted. The "most correct" answers gets checkmarked. (Please read the FAQ.) – IRTFM Mar 20 '14 at 03:00