Skip to content

Commit

Permalink
fix for #34
Browse files Browse the repository at this point in the history
  • Loading branch information
kassambara committed Sep 19, 2017
1 parent a65c913 commit a85f549
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

## Bug fixes

- Now `compare_means()` returns the same p-values as `stat_compare_means()` ([@wydty, #15](https://github.com/kassambara/ggpubr/issues/34)).
- `stat_compare_means()` now reacts to label = "p.format" when comparisons specified ([#28](https://github.com/kassambara/ggpubr/issues/28)).
- Now, the p.values are displayed correctly when ref.group is not the first group ([@sehufnkjesktgna, #15](https://github.com/kassambara/ggpubr/issues/27)).

Expand Down
14 changes: 12 additions & 2 deletions R/compare_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ compare_means <- function(formula, data, method = "wilcox.test",

# pairwise test
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
.test_pairwise <- function(data, formula, method = "wilcox.test", ...)
.test_pairwise <- function(data, formula, method = "wilcox.test",
paired = FALSE, pool.sd = !paired,
...)
{

x <- deparse(formula[[2]])
Expand All @@ -318,8 +320,16 @@ compare_means <- function(formula, data, method = "wilcox.test",
test <- match.fun(method)

test.opts <- list(x = .select_vec(data, x),
g = .select_vec(data, group), ...)
g = .select_vec(data, group),
paired = paired,
...)
if(method == "pairwise.wilcox.test") test.opts$exact <- FALSE
else if(method == "pairwise.t.test"){
if(missing(pool.sd)){
if(!paired) pool.sd <- FALSE
}
test.opts$pool.sd <- pool.sd
}

pvalues <- do.call(test, test.opts)$p.value %>%
as.data.frame()
Expand Down

0 comments on commit a85f549

Please sign in to comment.