I've ran a single-factor ANOVA on my data set and followed that with a TukeyHSD post-hoc test. I then used multcompLetters() to assign letters to the significant TukeyHSD results. I'm now trying to add the letters to an interaction plot. However, I can't seem to figure out a way to do this and have looked at several examples using boxplots but I am still lost. Any help or suggestions is greatly appreciated.
Here is the code I have used so far;
Below is a sample of data from the code I used - I am looking at whether poker player skill and/or the quality of the poker hand impact the amount of earnings in a poker game.
head(poker)
Skill Hand Limit Earnings
<chr> <chr> <chr> <dbl>
1 Expert Bad Fixed 4.00
2 Average Bad Fixed 5.55
3 Expert Good Fixed 9.45
4 Average Good Fixed 7.19
5 Expert Neutral Fixed 5.71
6 Average Neutral Fixed 5.32
# read in the csv file
poker <- read.csv("poker_skill.csv", header=T)
# create a model including an interaction
mod1 = lm(Earnings~Hand + Skill + Hand:Skill, data = poker)
Anova(mod1, type = "3")
# Performa Tukey's HSD test on mod1
TukeyHSD(aov(mod1))
# Use the multcompLetters4() function in the multcompView package to assign letters to
the significant results
Letters <- multcompLetters4(mod1, TukeyHSD(aov(mod1)), reversed = TRUE)
Letters
# Create an interaction plot and then add the Letters to the plot
pokerInt <- poker %>%
group_by(Hand,Skill) %>%
summarise(mean=mean(Earnings)
ggplot(poker, aes(x=factor(Hand), y=Earnings, colour=Skill)) +
geom_point(data=pokerInt, aes(y=mean)) +
geom_line(data=pokerInt, aes(y=mean, group=Skill)) +
labs(x="Poker Hand", y="Poker Earnings") +
theme_bw()
I am unsure on how I can add the Letters to the above interaction plot