Skip to content

Commit

Permalink
fix for #30
Browse files Browse the repository at this point in the history
  • Loading branch information
kassambara committed Dec 19, 2017
1 parent 998f06c commit 0ce3fea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Minor changes

- Significance levels can be now customized and passed to `stat_compare_means()` ([@jaison75, #45](https://github.com/kassambara/ggpubr/issues/30)).

## Bug fixes

- In `ggscatterhist()` the x variable was plotted two times, on both the plot x & y margins, instead of having, as expected, a) the x variable on the main plot x margin and 2) the y variable on the main plot y margin. This has been now fixed.
Expand All @@ -14,7 +16,7 @@

- New function `ggballoonplot()` added to visualize a contingency table.

- `ggdotchart()` can be now used to plot multiple groups with `position = position_dodge()` [@ManuelSpinola, #45](https://github.com/kassambara/ggpubr/issues/45).
- `ggdotchart()` can be now used to plot multiple groups with `position = position_dodge()` ([@ManuelSpinola, #45](https://github.com/kassambara/ggpubr/issues/45)).

- New function `ggscatterhist()` to create a scatter plot with marginal histograms, density plots and box plots.

Expand Down
22 changes: 21 additions & 1 deletion R/stat_compare_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,18 @@ stat_compare_means <- function(mapping = NULL, data = NULL,
if(.is_p.signif_in_mapping(mapping) | (label %in% "p.signif"))
{
map_signif_level <- c("****"=0.0001, "***"=0.001, "**"=0.01, "*"=0.05, "ns"=1)
if(hide.ns) names(map_signif_level)[5] <- " "
if(hide.ns) map_signif_level <- .hide_ns(map_signif_level)
}

if(!.is_empty(symnum.args)){

symnum.args.isok <- length(symnum.args$cutpoints == length(symnum.args$symbols))
if(!symnum.args.isok)
stop("Incorrect format detected in symnum.args. ",
"Check the documentation.")
map_signif_level <- symnum.args$cutpoints[-1] # the first element is 0 (the minimum p-value)
names(map_signif_level) <- symnum.args$symbols
if(hide.ns) map_signif_level <- .hide_ns(map_signif_level)
}

step_increase <- ifelse(is.null(label.y), 0.12, 0)
Expand Down Expand Up @@ -302,6 +313,15 @@ StatCompareMeans<- ggproto("StatCompareMeans", Stat,
mapping
}

# Hide NS in map_signif_level
.hide_ns <- function(x){
n <- names(x)
ns.pos <- which(n == "ns" | n == "NS")
if(!.is_empty(ns.pos)) n[ns.pos] = " "
names(x) <- n
x
}




0 comments on commit 0ce3fea

Please sign in to comment.