I ran a One-way Anova using this dataset:
data <- data.frame(pH = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5),
biosorption = c(30, 40, 34, 50, 51, 54, 60, 61, 62, 70, 71, 72, 80, 81, 82))
after which I got significant value that I run Tukey post hoc test all in R studio. I kept on seeing error messages
Error in TukeyHSD.aov(anova_result, “pH”) :
no factors in the fitted model
In addition: Warning message:
In replications(paste(“~”, xx), data = mf) : non-factors ignored: pH
I tried the Tukey post hock after got stuck I tried online help but couldn’t solved.
The problem here is you are trying to fit an anova with just 2 continuous variables, which isn’t possible. A lot of the stats functions in R
will fix minor mistakes it catches and move on. In this case, it looks like aov()
will fit a normal linear regression if the data fits rather than an anova.
I’m assuming you mean to use pH as a categorical variable, rather than a linear one. If this isn’t the case please provide details about the analysis and why you are trying to fit an ANOVA.
data <- data.frame(pH = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5),
biosorption = c(30, 40, 34, 50, 51, 54, 60, 61, 62, 70, 71, 72, 80, 81, 82))
anova_results <- aov(data = data, biosorption ~ as.factor(pH))
TukeyHSD(anova_result)
This will emit:
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = biosorption ~ as.factor(pH), data = data)
$`as.factor(pH)`
diff lwr upr p adj
2-1 17.000000 10.131522 23.86848 0.0000765
3-1 26.333333 19.464855 33.20181 0.0000014
4-1 36.333333 29.464855 43.20181 0.0000001
5-1 46.333333 39.464855 53.20181 0.0000000
3-2 9.333333 2.464855 16.20181 0.0081953
4-2 19.333333 12.464855 26.20181 0.0000245
5-2 29.333333 22.464855 36.20181 0.0000005
4-3 10.000000 3.131522 16.86848 0.0051246
5-3 20.000000 13.131522 26.86848 0.0000181
5-4 10.000000 3.131522 16.86848 0.0051246