Skip to content

Commit

Permalink
Now, ref.group option is also considereded in two samples mean compar…
Browse files Browse the repository at this point in the history
…isons #118
  • Loading branch information
kassambara committed Nov 2, 2018
1 parent 0132e37 commit ace05f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

## Bug fixes

- The option `ref.group` was only considered when the grouping variable contains more than two levels. In that case, each level is compared against the specified reference group. Now, `ref.group` option is also considereded in two samples mean comparisons ([@OwenDonohoe, #118](https://github.com/kassambara/ggpubr/issues/118)

- Now, `ggqqplot()` reacts to the argument `conf.int.level` ([@vsluydts, #123](https://github.com/kassambara/ggpubr/issues/123)
- Added error bar color is now inherited from the main plot ([@JesseRop, #109](https://github.com/kassambara/ggpubr/issues/109)

Expand Down
3 changes: 3 additions & 0 deletions R/compare_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ compare_means <- function(formula, data, method = "wilcox.test",
if(is.factor(group.vals)) group.levs <- levels(group.vals)
else group.levs <- unique(group.vals)

if(ref.group %in% group.levs){
data[, group] <- stats::relevel(group.vals, ref.group)
}

if(ref.group == ".all."){
data <- data %>%
Expand Down
3 changes: 2 additions & 1 deletion R/stat_compare_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ StatCompareMeans<- ggproto("StatCompareMeans", Stat,
#::::::::::::::::::::::::::::::::::::::::::::::::::
method.args <- method.args %>%
.add_item(data = data, method = method,
paired = paired, ref.group = ref.group,
paired = paired, ref.group = as.character(ref.group),
symnum.args = symnum.args)

if(.is.multiple.grouping.vars){
Expand All @@ -212,6 +212,7 @@ StatCompareMeans<- ggproto("StatCompareMeans", Stat,
.add_item(formula = y ~ x)
.test <- do.call(compare_means, method.args)
}
print(.test)

pvaltxt <- ifelse(.test$p < 2.2e-16, "p < 2.2e-16",
paste("p =", signif(.test$p, 2)))
Expand Down

0 comments on commit ace05f9

Please sign in to comment.