[R-sig-eco] Error in lm AND questions on betadisper()
Ciraolo, Alessia Caterina
@cc|r@o|o @end|ng |rom mun@c@
Tue Feb 8 12:24:01 CET 2022
Hi everyone,
I would like to ask you two (basic) questions about two different topics,
please.
1) I need to run a simple lm between "Oxygen concentration" (numeric) and
"Treatment" (2 levels-chr) at each habitat (3 levels-chr). However, when I
run one lm at Habitat A, everything is fine but then when I run it at
Habitat B, I get the following error:
"Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels".
Looking online, It says that one of the factors that I am using have either
only 1 distinct value or are NA, but doesn't look like this to me.
Could you explain me why this happens and how to fix it , please?
2) I need to run a PERMANOVA analysis with interaction term . However
before that, I was testing the assumptions with betadisper but I have
trouble in making the variable "group" in betadisper. Usually, it usually
consists in a factor or an object with a single level, is it right? But how
does it work with the interaction term, please?
Below you can find my code:
mod3 <- betadisper(distance, group)
mod3
anova(mod3)
permutest(mod3, pairwise = TRUE, permutations = 999)
perm <- adonis(distance ~ Habitat *Treat, data=BF,
permutations= 9999, method="euclidean")
perm
If any of you can help me to understand and fix the problems, it would be
very much appreciated.
I am happy to provide more info if needed!
Many thanks in advance!
Regards,
Aessia
[[alternative HTML version deleted]]
More information about the R-sig-ecology
mailing list