The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
library(cld)
The make_cld() function works seamlessly with multiple
input formats, making it a versatile tool for creating compact letter
displays from various statistical packages and custom data.
| Input Type | Example Packages | Function Examples |
|---|---|---|
pairwise.htest |
base R | pairwise.t.test(),
pairwise.wilcox.test() |
PMCMR / PMCMRplus |
PMCMR, PMCMRplus | kwAllPairsConoverTest(), dunnTest() |
data.frame (rstatix) |
rstatix | games_howell_test(), tukey_hsd() |
PostHocTest |
DescTools | ConoverTest(), DunnettTest() |
matrix |
Custom | Symmetric p-value matrices |
data.frame |
Custom | Custom comparison data frames |
formula |
Custom | Formula interface for data frames |
# Pairwise Wilcoxon rank sum test
result <- pairwise.wilcox.test(chickwts$weight, chickwts$feed, exact = FALSE)
make_cld(result)
#> Compact Letter Display (CLD)
#> Signif. level (alpha): 0.05
#> Method: Wilcoxon rank sum test with continuity correction
#>
#> group cld spaced_cld
#> casein a a__
#> horsebean b _b_
#> linseed bc _bc
#> meatmeal ac a_c
#> soybean c __c
#> sunflower a a__
# Pairwise t-test
result2 <- pairwise.t.test(chickwts$weight, chickwts$feed)
make_cld(result2, alpha = 0.01) # More stringent threshold
#> Compact Letter Display (CLD)
#> Signif. level (alpha): 0.01
#> Method: t tests with pooled SD
#>
#> group cld spaced_cld
#> casein a a__
#> horsebean b _b_
#> linseed bc _bc
#> meatmeal ac a_c
#> soybean c __c
#> sunflower a a__
You can use symmetric matrices of p-values directly:
# Create a symmetric matrix of p-values
m <- matrix(c(
1.00, 0.22, 0.05, 0.00,
0.22, 1.00, 0.17, 0.01,
0.05, 0.17, 1.00, 0.22,
0.00, 0.01, 0.22, 1.00
), nrow = 4)
rownames(m) <- colnames(m) <- c("GroupA", "GroupB", "GroupC", "GroupD")
# Generate CLD
make_cld(m, alpha = 0.05)
#> Compact Letter Display (CLD)
#> Signif. level (alpha): 0.05
#> Method: matrix
#>
#> group cld spaced_cld
#> GroupA a a_
#> GroupB a a_
#> GroupC ab ab
#> GroupD b _b
The package supports results from PMCMRplus for non-parametric post-hoc tests:
library(PMCMRplus)
# Kruskal-Wallis post-hoc test
kw_result <- kwAllPairsConoverTest(count ~ spray, data = InsectSprays)
make_cld(kw_result)
# Dunn test
dunn_result <- kwAllPairsDunnTest(count ~ spray, data = InsectSprays)
make_cld(dunn_result)
The rstatix package provides tidyverse-compatible statistical tests. Since rstatix returns data frames, you need to specify the column names for groups and p-values:
library(rstatix)
# Games-Howell test (for unequal variances)
gh_result <- games_howell_test(PlantGrowth, weight ~ group)
make_cld(gh_result, gr1_col = "group1", gr2_col = "group2", p_val_col = "p.adj")
# Tukey HSD test
tukey_result <- tukey_hsd(PlantGrowth, weight ~ group)
make_cld(tukey_result, gr1_col = "group1", gr2_col = "group2", p_val_col = "p.adj")
# Pairwise t-test
pwt_result <- pairwise_t_test(PlantGrowth, weight ~ group)
make_cld(pwt_result, gr1_col = "group1", gr2_col = "group2", p_val_col = "p.adj")
The DescTools package offers various post-hoc tests:
library(DescTools)
# Conover test
conover_result <- ConoverTest(count ~ spray, data = InsectSprays)
make_cld(conover_result)
# Dunnett test (comparison to control)
dunnett_result <- DunnettTest(weight ~ group, data = PlantGrowth)
make_cld(dunnett_result)
You can create CLDs from custom comparison results stored in data frames:
# Custom comparison results
comparisons <- data.frame(
group1 = c("Treatment_A", "Treatment_A", "Treatment_B"),
group2 = c("Treatment_B", "Treatment_C", "Treatment_C"),
p.adj = c(0.9, 0.02, 0.03)
)
make_cld(comparisons, alpha = 0.05)
#> Compact Letter Display (CLD)
#> Signif. level (alpha): 0.05
#> Method: data.frame
#>
#> group cld spaced_cld
#> Treatment_B a a_
#> Treatment_C b _b
#> Treatment_A a a_
If your data frame uses different column names, specify them:
# Data frame with custom column names
my_comparisons <- data.frame(
first_group = c("A", "A", "B"),
second_group = c("B", "C", "C"),
adjusted_p = c(0.9, 0.02, 0.03)
)
make_cld(my_comparisons,
gr1_col = "first_group",
gr2_col = "second_group",
p_val_col = "adjusted_p",
alpha = 0.05
)
#> Compact Letter Display (CLD)
#> Signif. level (alpha): 0.05
#> Method: data.frame
#>
#> group cld spaced_cld
#> B a a_
#> C b _b
#> A a a_
The formula interface provides a convenient way to specify p-values and comparison labels. There are two formula formats available:
No hyphens are allowed in group names when using this format as they are used as separators.
# Using formula for data frames with comparison strings
my_data <- data.frame(
Comparison = c("A-B", "A-C", "B-C"),
p_value = c(0.12, 0.001, 0.045),
p_adjusted = c(0.18, 0.003, 0.068)
)
# Use the adjusted p-values
make_cld(p_adjusted ~ Comparison, data = my_data)
#> Compact Letter Display (CLD)
#> Signif. level (alpha): 0.05
#> Method: formula
#>
#> group cld spaced_cld
#> A a a_
#> B ab ab
#> C b _b
# Or use the raw p-values
make_cld(p_value ~ Comparison, data = my_data)
#> Compact Letter Display (CLD)
#> Signif. level (alpha): 0.05
#> Method: formula
#>
#> group cld spaced_cld
#> A a a_
#> B a a_
#> C b _b
When your group names contain hyphens or special characters, use the two-variable formula format which specifies groups separately:
# Data with group names containing hyphens
my_data2 <- data.frame(
group1 = c("Treatment-A", "Treatment-A", "Treatment-B"),
group2 = c("Treatment-B", "Treatment-C", "Treatment-C"),
p_adjusted = c(0.18, 0.003, 0.068)
)
# Two-variable formula (handles hyphens automatically)
make_cld(p_adjusted ~ group1 + group2, data = my_data2)
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.