How to solve the problem of "Error in comp[[i]] : subscript out of bounds" to mke compact letter display in two ways anova analysis?

I have a problem with "Error in comp[[i]] : subscript out of bounds"

I want to indicate compact letter display in my analysis but it did not work.
I have tried to find some solution in internet but it failed.
Do anyone can help me?
this is my data data

and this is the script

library(datasets)
library(ggplot2)
library(multcompView)
library(dplyr)
library(datasets)
library(tidyverse)
library(multcomp)

Data = read.csv("data.csv", h= TRUE)
qplot(x = species, y = Ratio, geom = "point", data = Data) +
  facet_grid(.~Strain)


# creating a variable as factor for the ANOVA
Data$Strain <- as.factor(Data$Strain)
Data$species <- as.factor(Data$species)
str(Data)

# analysis of variance
anova <- aov(Ratio ~ Strain*factor(species), data = Data)
summary(anova)

# table with factors, means and standard deviation
data_summary <- group_by(Data, Strain, species) %>%
  summarise(mean=mean(Ratio), sd=sd(Ratio)) %>%
  arrange(desc(mean))
print(data_summary)

# Tukey's test
tukey <- TukeyHSD(anova)
print(tukey)


# compact letter display
coba = multcompLetters4(anova, tukey)
print(coba)

# creating the compact letter display
tukey.cld <- multcompLetters4(anova, tukey)
print(tukey.cld)

this is what I want to get ---> I want to get the letter indicate in my data
image

Please help me!
Thank you so much

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.