Problem for add letters in plot using gplot2 and ggeffects

I'd like to add the significance letters to a plot using ggeffects and ggplot2 packages. In my case:

    # Packages
    library(ggeffects)
    library(dplyr)
    library(glmmTMB)
    library(multcomp)
    library(lsmeans)
    library(ggplot2)
    
    # My data set
    ds <- read.csv("https://raw.githubusercontent.com/Leprechault/trash/main/temp_ger_ds.csv")
    str(ds)
    #'data.frame':  140 obs. of  4 variables:
    # $ temp       : chr  "constante" "constante" "constante" "constante" ...
    # $ generation : chr  "G0" "G0" "G0" "G0" ...
    # $ development: int  22 24 22 27 27 24 25 26 27 18 ...

#General model:

    mTCFd <- glmmTMB(development ~ temp * generation, data = ds,
                   family = ziGamma(link = "log")) 

#3 combinations plot:

    #1) Plot for temp
        lsm.mTCFd.temp <- lsmeans(mTCFd, c("temp"))
        lt<-cld(lsm.mTCFd.temp, Letters=letters, decreasing = TRUE)
        ds <- ds %>% mutate(x_1=  1+(readr::parse_number(generation)-2)*0.05, 
                            group = generation)
        df_gg <-ggpredict(mTCFd, terms = c("temp"))%>% 
          mutate(x_1=  1+(readr::parse_number(as.character(group))-2)*0.05)
        df_gg %>% plot(add.data = TRUE) + 
          geom_text(aes(x = x_1, label = lt[,7]), vjust = -0.5, show.legend = FALSE) 
    
    #2) Plot for generation
        lsm.mTCFd.gera <- lsmeans(mTCFd, c("generation"))
        lt<-cld(lsm.mTCFd.gera, Letters=letters, decreasing = TRUE)
        ds <- ds %>% mutate(x_1=  1+(readr::parse_number(generation)-2)*0.05, 
                            group = generation)
        df_gg <-ggpredict(mTCFd, terms = c("generation"))%>% 
          mutate(x_1=  1+(readr::parse_number(as.character(group))-2)*0.05)
        df_gg %>% plot(add.data = TRUE) + 
          geom_text(aes(x = x_1, label = lt[,7]), vjust = -0.5, show.legend = FALSE) 
    
    #3) Plot for temp and generation interaction
    
        lsm.mTCFd.temp.gera <- lsmeans(mTCFd, c("temp","generation"))
        lt<-cld(lsm.mTCFd.temp.gera , Letters=letters, decreasing = TRUE)
        ds <- ds %>% mutate(x_1=  1+(readr::parse_number(generation)-2)*0.05, 
                            group = generation)
        df_gg <-ggpredict(mTCFd, terms = c("temp","generation"))%>% 
          mutate(x_1=  1+(readr::parse_number(as.character(group))-2)*0.05)
        df_gg %>% plot(add.data = TRUE) + 
          geom_text(aes(x = x_1, label = lt[,8]), vjust = -0.5, show.legend = FALSE) 

But I always as output:

    Raw data not available.
    Error in if (attr(x, "logistic", exact = TRUE) == "1" && attr(x, "is.trial",  : 
      missing value where TRUE/FALSE needed

Please, any help with it?

This topic was automatically closed 21 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.