I have a data frame and have done an ANOVA between the data. After the ANOVA I want to use one of the resulting columns to do a calculation and create a new column with the mutate()
function. However, an error appears indicating that this operation cannot be done on an anova
class object:
Error: `x` must be a vector, not a <anova_test/data.frame/rstatix_test> object.
Can someone help me perform calculations (F + 1
) with the F column of the ANOVA result?
library(dplyr)
library(rstatix)
Temperature <- factor(c(rep("cold", times = 4),
rep("hot", times = 4)),
levels = c("cold", "hot"))
Light <- factor(rep(c(rep("blue", times = 2),
rep("yellow", times = 2)),
times = 2),
levels = c("blue", "yellow"))
Result <- c(90.40, 85.20, 21.70, 25.30,
75.12, 77.36, 6.11, 10.8)
Data <- data.frame(Temperature, Light, Result)
NewColumn <- Data %>%
anova_test(formula = Result ~ Temperature*Light) %>%
mutate(New= `F` + 1) #<-------- Not working