Format of ANOVA Command is aov(Dependent_variable~independent_variable, data) We need a 2 column data with method in first column and score in second start with Vector for Each Column
method1.score <- c(95,91,89,90,99,88,96,98,95)
method2.score <- c(83,89,85,89,81,89,90,82,84,80)
method3.score <- c(68,75,79,74,75,81,73,77)
Then create a single vector that consists of all three scores
Score <- c(method1.score,method2.score,method3.score)
Create a vector consisting of the names of the methods, matched up against the scores.
Method <- rep(c("method1","method2","method3"),
times=c(length(method1.score),
length(method2.score),
length(method3.score)))
The dataframe now becomes
Training.frame <- data.frame(Method,Score)
Now apply ANOVA format is aov(Dependent_variable~independent_variable, data)
analysis <- aov(Score~Method,data=Training.frame)
summary(analysis)
## Df Sum Sq Mean Sq F value Pr(>F)
## Method 2 1402.7 701.3 45.82 6.38e-09 ***
## Residuals 24 367.3 15.3
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
visualising the results
library(ggplot2)
## Registered S3 methods overwritten by 'ggplot2':
## method from
## [.quosures rlang
## c.quosures rlang
## print.quosures rlang
Lets make a boxplot
ggplot(Training.frame,aes(x=Method,y=Score))+
stat_boxplot(geom="errorbar",width=.5)+
geom_boxplot()