首页 > 解决方案 > cldList() 函数在添加紧凑型字母显示时表现异常

问题描述

我在这里问了一个问题,但现在面临另一个问题

cldList()从包中运行后rcompanion,它给了我一个表格,显示了每组的紧凑字母显示,但是,尽管与其他组没有显着差异,但有些组没有显示任何字母。

数据太大所以我在 这里上传

这是一个错误还是我做错了什么。

我正在使用的代码是这个

library(FSA)
library(multcompView)
library(rcompanion)
library(ggplot2)
library(ggpubr)
library(tidyr)

raw_df <- read.csv("raw_data.csv")


#After performing Kruskal-Wallis H test, I found significant groups and performed the post hoc test using dunnTest() using the code below

bells <- dunnTest(Group ~ as.factor(Color_Score), method = "bh", data = raw_df)

#I save the P values into a separate variable
piano <- bells$`res`

#After the Dunn Test, I tried to get the compact letter displays.

flute <- cldList(P.adj ~ Comparison, data = piano, threshold = 0.05) 

#This is where the problem starts, overall, I have 40 groups to compare but would only return letters for 38 groups

#I tried plotting the boxplot and adding the compact letter using the code below

ggboxplot(raw_df, x = "Group", y = "Color_Score", 
          combine = FALSE, 
          x.text.angle = 360,
          orientation = "vertical",
          ylab = "Measurement (cm)",
          xlab = "Group", 
          color = "Group",
          fill = "Group", 
          notch = FALSE,
          ggtheme = theme_gray()) + 
            font("xy.text", size = 7, color = "black") + 
            theme(legend.position = "None", 
             axis.text.x =element_text(color = "black")) +  
            color of the y-axis (Measurement) tick labels
            geom_text(data  = flute, 
                      aes(x = Group, y = 12, angle = 90,
                      label = Letter),
                      position = position_nudge(x = 0.1),
                      hjust = 0,
                      color = "red")

有人经历过吗?我试图搜索但找不到任何答案。

标签: rggplot2boxplot

解决方案


我是该cldList()功能的作者。由于该函数旨在处理来自不同函数的不同输出,因此默认情况下它会删除空格、零和等号等字符,以便将结果传递给multcompView::multcompLetters. 通过删除零,在这种情况下,它C1C10. 下面解决了这个问题:

flute <-
  cldList(P.adj ~ Comparison,
          data = bells$res,
          threshold = 0.05,
          remove.zero = FALSE)
flute

推荐阅读