I'm doing a three way ANOVA and I want to do a post_hoc analysis on it. To make a comparison by groups, I saw that the emmeans_test from the package emmeans was the best option. My problem is simple, when I run my code, it doesn't work because R doesn't find the function "emmeans_test". I don't understand why, because I have install the package emmeans and run the library in my code... Can someone explain me what to do please ?
Here is my code, just in case :
library(emmeans)
res <- donnees_tot_g_J4 %>%
group_by(quality, temperature) %>%
emmeans_test(growth_rate ~ quantity, p.adjust.method = "bonferroni")
res
Error in emmeans_test(., growth_rate ~ quantity, p.adjust.method = "bonferroni") :
could not find function "emmeans_test"
CodePudding user response:
Function emmeans_test
is not from emmeans but from rstatix. So you need:
if (!require(rstatix)) install.packages("rstatix")
library(rstatix)
Thank you, it was that ! Sorry for the dumb question.
Don't worry. The name is indeed misleading. And in fact, neither package depends on or imports the other. rstatix only suggests that it could enhance emmeans.
Thanks for the useful feedback from dipetkov.
Actually, rstatix calls emmeans to do the actual analysis; it's not enhancing anything. It can't deal for example with a model that omits the three-way interactions.
Sorry for the confusion. My statement is based on what I saw from the CRAN page for rstatix. Surprisingly, emmeans is in neither "depends" nor "imports"; only in "suggests". Don't know how that emmeans_test
would work if the package does not import emmeans in the first place.
I strongly suggest to the OP to learn how to do their analysis with
lm()
followed byemmeans()
, as they'll have lots more flexibility (and confidence in the results).
Thanks. I update my answer to pass this suggestion to OP, as well as future readers.