3

I am performing a CAP analysis (vegan, R) on a species abundance table, with 2 explaining factors (Location and Complexity_Watson) and one explaining continuous variable (Depth..m.). Below you will find some of my code:

species.cap=capscale(Species.MVA.DOV ~ Location + Depth..m. + 
   Complexity_Watson, data=Habitat.MVA.DOV, distance="bray", na.action=na.omit)

However, summary(species.cap) yields the location & complexity as both constraining (continuous) variables and constraining factors.

How can I make sure it only enters them as factors? (I tried adding factor() but that yielded the same result).

When I want to plot the environmental variables, it creates both arrows and centroids for location and complexity, while I only want centroids (and an arrow for depth).

Could someone help me out?

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453
JVrooman
  • 31
  • 1

1 Answers1

1

Use as.factor to change the variables to factors in the dataframeHabitat.MVA.DOV

Habitat.MVA.DOV$Location <- as.factor(Habitat.MVA.DOV$Location)
Habitat.MVA.DOV$Complexity_Watson <- as.factor(Habitat.MVA.DOV$Complexity_Watson)

For the plotting question you have to realize that plot is calling plot.cca. Use the help section in plot.cca to pinpoint the solution to your question.

I think what you want is:

plot(species.cap, display = "cn") #cn stands for centroid, see help for other options
?plot.cca # gets you to the documentation/help on plot.cca

Also, the vegan tutorial is a great reference with helpful examples.

Collin
  • 440
  • 1
  • 4
  • 11
  • Current **vegan** release (2.3-0) indeed requires that your factors are strictly factors and not only factor-looking character strings. This will change in the next release (2.3-1) which also finds centroids for character variables that were not formally defined as factors. This concerns all funtions for constrained ordination (`capscale`, `rda`, `cca`) – Jari Oksanen Sep 11 '15 at 07:27