I obtain the boxplot using this dataframe
library(reshape2)
library(ggplot2)
ID <- c("DJ45","DJ46","DJ47","DJ48","DJ49","DJ53","DJ54","DJ55","DJ56","DJ57")
Tool <- c("Tool_A", "Tool_A", "Tool_A", "Tool_A", "Tool_A", "Tool_B", "Tool_B", "Tool_B", "Tool_B", "Tool_B")
Name <- c("CMP", "CMP", "CMP", "CMP", "CMP", "CMP", "CMP", "CMP", "CMP", "CMP")
MS1 <- c(51,55,50,59,50,47,48,42,43,46)
MS2 <- c(13,11,14,11,10,17,18,17,20,21)
MS3 <- c(2,3,2,5,6,4,9,6,4,4)
MS4 <- c(16,13,14,11,16,16,18,16,19,15)
MS5 <- c(3,6,3,6,3,4,4,8,5,4)
MS6 <- c(7,7,5,5,8,9,8,6,6,9)
df1 <- data.frame(ID,Tool,Name,MS1,MS2,MS3,MS4,MS5,MS6)
df2<-melt(df1,id.var=c("ID","Tool","Name"))
p2 <- ggplot(df2, aes(x=factor(Tool),y=value,fill=factor(Tool)))+
geom_boxplot() + labs(title="CMP") +facet_wrap(~variable)
p2
we get this plot,
I then compare the different tools using t-test and obtain the p values for each measurements like this.
t.test(MS1 ~ Tool, df1)
t.test(MS2 ~ Tool, df1)
I would like to include the p-value for each group in the plots. I referred to this link but confused how to code it to my problem. Kindly provide inputs/direction on how to solve this problem.