Skip to content

Commit dfa6526

Browse files
committed
fix: bug in kruskalmc
(due to changes in pgirmess output)
1 parent 4cc4994 commit dfa6526

File tree

6 files changed

+28
-20
lines changed

6 files changed

+28
-20
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggtukey
2-
Title: Compact Letter Displays for 'ggplot2'
3-
Version: 0.3.0
2+
Title: Compact Letter Displays for Multiple Comparisons in 'ggplot2'
3+
Version: 0.4.0
44
Authors@R:
55
person("Ethan", "Bass", , "ethanbass@gmail.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0002-6175-6739"))

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# ggtukey 0.3.0 dev
1+
# ggtukey 0.4.0
2+
3+
* Fixed bug when using `kruskalmc` (Dunn test) due to changes in `pgirmess::kruskalmc` output.
4+
5+
# ggtukey 0.3.0
26

37
* Added additional parameters to `geom_tukey` (`geom`, `color`, `fill,` & `alpha`) for further customization of letters.
48

R/utils.R

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
#' Do Tukey Test and calculate letter placement
1+
#' Perform Tukey Test and calculate letter placement
32
#' @importFrom stats TukeyHSD aov as.formula median quantile reorder
43
#' @importFrom dplyr left_join
54
#' @importFrom rlang as_name
@@ -28,13 +27,14 @@ get_tukey_letters <- function(data, x, y, group = NULL, test = c("tukey", "krusk
2827
# stop("Factor names cannot contain dashes. Please recode factor levels before proceeding.")
2928
# }
3029
if (inherits(x, "quosure") & is.null(group)){
31-
letters.df <- place_tukey_letters(data, as_name(x), as_name(y), test = test,
32-
where = where, threshold = threshold)
30+
letters.df <- place_tukey_letters(data = data, x = as_name(x), y = as_name(y),
31+
test = test, where = where,
32+
threshold = threshold)
3333
} else{
3434
if (type == "two-way"){
35-
letters.df <- place_tukey_letters(data, sapply(x, as_name), as_name(y),
36-
test = test, where = where,
37-
threshold = threshold)
35+
letters.df <- place_tukey_letters(data = data, x = sapply(x, as_name),
36+
y = as_name(y), test = test,
37+
where = where, threshold = threshold)
3838
} else if (type == "one-way"){
3939
letters.df <- purrr::map_dfr(unique(data[[as_name(group)]]), function(gr){
4040
data %>% filter(!!group == gr) %>%
@@ -47,6 +47,7 @@ get_tukey_letters <- function(data, x, y, group = NULL, test = c("tukey", "krusk
4747
letters.df
4848
}
4949

50+
#' Place Tukey Letters
5051
#' @noRd
5152
place_tukey_letters <- function(data, x, y, test = c("tukey", "kruskalmc"),
5253
where = c("box","whisker"),
@@ -56,16 +57,16 @@ place_tukey_letters <- function(data, x, y, test = c("tukey", "kruskalmc"),
5657
xlab <- x
5758
} else {
5859
form <- as.formula(paste(y, paste(x, collapse="*"), sep="~"))
59-
xlab<-paste(x, collapse=":")
60+
xlab <- paste(x, collapse=":")
6061
data[,xlab] <- apply(data[,x], 1, paste, collapse = ":")
6162
}
6263
if (test == "tukey"){
6364
tukey <- TukeyHSD(aov(form, data = data))[[xlab]][,4]
6465
tukey <- tukey[which(!is.na(tukey))]
6566
letters.df <- data.frame("Letter" = multcompLetters(tukey, threshold = threshold)$Letters)
6667
} else if (test == "kruskalmc"){
67-
test <- pgirmess::kruskalmc(form, data=data, probs = threshold)
68-
diff <- test$dif.com[,"difference"]
68+
test <- pgirmess::kruskalmc(form, data = data, probs = threshold)
69+
diff <- test$dif.com[,"stat.signif"]
6970
names(diff) <- rownames(test$dif.com)
7071
letters.df <- data.frame("Letter" = multcompLetters(diff)$Letters)
7172
}
@@ -91,31 +92,33 @@ place_tukey_letters <- function(data, x, y, test = c("tukey", "kruskalmc"),
9192
letters.df
9293
}
9394

95+
#' Calculate standard error of the mean error bar
9496
#' @importFrom stats sd
9597
#' @noRd
9698
get_sem <- function(x){
9799
mean(x) + sd(x)/sqrt(length(x))
98100
}
99101

102+
#' Calculate standard deviation error bar
100103
#' @importFrom stats sd
101104
#' @noRd
102105
get_sd <- function(x){
103106
mean(x) + sd(x)
104107
}
105108

109+
#' Calculate cl normal error bar
106110
#' @noRd
107111
get_cl_normal <- function(x){
108112
Hmisc::smean.cl.normal(x)[[3]]
109113
}
110114

115+
#' Calculate cl boot error bar
111116
#' @noRd
112117
get_cl_boot <- function(x){
113118
Hmisc::smean.cl.boot(x)[[3]]
114119
}
115120

116121
#' Check whether color specifications exists.
117-
#'
118-
#' @export
119122
#' @import grDevices
120123
#' @description Function to check whether all specified colors are
121124
#' actual colors.
@@ -146,7 +149,7 @@ get_cl_boot <- function(x){
146149
#' test <- c('#FH0000', 3, '#FF00991', 'lavendel', '#AABBCCFFF')
147150
#' is.color(test)
148151
#' is.color(test, return.colors=TRUE)
149-
#'
152+
#' @export
150153
is.color <- function(x, return.colors = FALSE) {
151154
# numeric colors, max 8
152155
if (is.numeric(x)) {
@@ -171,12 +174,14 @@ is.color <- function(x, return.colors = FALSE) {
171174
}
172175
}
173176

177+
#' Calculate quantile
174178
#' @importFrom stats quantile
175179
#' @noRd
176180
get_quantile <- function(x){
177181
quantile(x, na.rm=TRUE)[4]
178182
}
179183

184+
#' Calculate boxplot whisker
180185
#' @importFrom stats IQR
181186
#'@noRd
182187
get_whisker <- function(x){

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ For more examples and details on different options for customization, please con
5454

5555
You can cite `ggtukey` as follows:
5656

57-
Bass, E. (2022). ggtukey: Compact Letter Displays for 'ggplot2' (v0.3.0). (https://ethanbass.github.io/ggtukey/).
57+
Bass, E. (2022). ggtukey: Compact Letter Displays for 'ggplot2' (v0.4.0). (https://ethanbass.github.io/ggtukey/).
5858

5959
# Further Reading
6060

inst/CITATION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ citEntry(
55
title = "ggtukey: Compact Letter Displays for 'ggplot2'",
66
author = "Ethan Bass",
77
year = "2023",
8-
note = "version 0.3.0",
8+
note = "version 0.4.0",
99
url = "https://ethanbass.github.io/ggtukey/",
1010
doi = "",
1111
textVersion = paste("Bass, E. (2023).",
12-
"ggtukey: Compact Letter Displays for 'ggplot2' (version 0.3.0)."
12+
"ggtukey: Compact Letter Displays for 'ggplot2' (version 0.4.0)."
1313
)
1414
)

man/is.color.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)