2023-07-01

How to display letters to pairwise comparison plot?

How can I display letters on a ggstatsplot package plot for Kruskal Walllis test? This is a reproducible example based on this question.

set.seed(123)

# Create vector for number of cases per month
cases_per_month <- c(10, 25, 20, 20, 25, 20, 19, 5)

# Create vector for months (April to November)
months <- c("April", "May", "June", "July", "August", "September", "October", "November")

# Create empty vectors for final dataset
dataset <- data.frame(mean_severity = numeric(), month = character())

# Generate dataset
dat <- list()

for (i in 1:length(months)) {
  month <- rep(months[i], cases_per_month[i])
  severity <- sample.int(n = 10, size = cases_per_month[i], replace = TRUE)
  
  # generate some differences in the sample
  if (i %in% c(1, 4, 7)){
    severity <- severity^2
  }
  
  temp_data <- data.frame(mean_severity = severity, month = month)
  dat[[i]] <- rbind(dataset, temp_data)
}

# Using rbind to combine rows
dat <- do. Call(rbind, dat) 

enter image description here

Currently, I have bars showing p-values. I want letters instead of bars showing p values. The question has been answered here. Apparently, AddLetters function should show letters instead of p values as shown below in his example, but it runs indefinitely without displaying any letters in my case. Is there any other way of displaying letters?

Example plot where letters are shown instead of bars here enter image description here



No comments:

Post a Comment