I run adonis on community data and environmental matrix (that contains a factor of two levels and 6 continuous variables) using Bray-Curtis and I always take 1 df but this is not the case. Probably there is a bug here.
See also the example in adonis
data(dune)
data(dune.env)
str(dune.env)
adonis(dune ~ Management*A1, data=dune.env, permutations=99)
Although A1 is a numeric variable the result provides 1 df.
In the model:
The main effect of
A1uses a single degree of freedom because it is a continuous variable. The interaction betweenManagementandA1uses 3 additional degree's of freedom as there is one additional "effect" ofA1per level ofManagement.This is all expected and there is certainly no bug illustrated in
adonis()from this model.Importantly, you must insure that factor variables are coded as factors otherwise, for example if the categories are coded as integers, then R will still interpret those variables as continuous/numeric. It will only interpret them as factors if coerced to the
"factor"class. Check the output ofstr(df), wheredfis your data frame containing the predictor variables (covariates; the things on the right-hand side of~), and insure that each factor variable is of the appropriate class. For example, thedune.envdata are:which indicates that
Managementis a factor,A1is numeric (it is the thickness of the A1 soil horizon), and the remaining variables are ordered factors (but still factors; they work correctly in R's omdel formula infrastructure).