Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions R/geom_signif.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#' annotations per facet.
#' @param na.rm If `FALSE` (the default), removes missing values with
#' a warning. If `TRUE` silently removes missing values.
#' @param correction Should the p value be corrected for multiple testing by false discovery rate ?
#' "none" by default. p.adjust.methods: c("holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none")
#' @param orientation The orientation of the layer. The default (‘NA’)
#' automatically determines the orientation from the aesthetic mapping.
#' In the rare event that this fails it can be given explicitly by setting
Expand Down Expand Up @@ -104,6 +106,7 @@ stat_signif <- function(mapping = NULL,
vjust = 0,
parse = FALSE,
manual = FALSE,
correction="none",
orientation = NA,
...) {
if (manual) {
Expand Down Expand Up @@ -137,6 +140,7 @@ stat_signif <- function(mapping = NULL,
parse = parse,
manual = manual,
na.rm = na.rm,
correction=correction,
orientation = orientation,
...
)
Expand Down Expand Up @@ -271,6 +275,7 @@ geom_signif <- function(mapping = NULL,
vjust = 0,
parse = FALSE,
manual = FALSE,
correction="none",
orientation = NA,
...) {
params <- list(na.rm = na.rm, ...)
Expand Down Expand Up @@ -327,6 +332,7 @@ geom_signif <- function(mapping = NULL,
vjust = vjust,
parse = parse,
manual = manual,
correction=correction,
orientation = orientation
)
)
Expand Down Expand Up @@ -427,6 +433,7 @@ StatSignif <- ggplot2::ggproto(
step_increase,
tip_length,
manual,
correction,
flipped_aes = FALSE) {
data <- ggplot2::flip_data(data, flipped_aes)
scales <- ggplot2::flip_data(scales, flipped_aes)
Expand Down Expand Up @@ -467,6 +474,7 @@ StatSignif <- ggplot2::ggproto(
group_2 <- complete_data$y[complete_data$x == scales$x$map(comp[2]) &
complete_data$PANEL == data$PANEL[1]]
p_value <- do.call(test, c(list(group_1, group_2), test.args))$p.value
p_value = p.adjust(p_value, method=correction, n=length(comparisons))
if (is.numeric(map_signif_level)) {
temp_value <- names(which.min(map_signif_level[which(map_signif_level > p_value)]))
if (is.null(temp_value)) {
Expand Down