From 4dcc95b59abe745e8edc420b52877a20aee31485 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Fri, 31 May 2024 21:18:03 +0200 Subject: [PATCH] Use scalar logical operators in conditionals (#139) --- R/geom_signif.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/geom_signif.R b/R/geom_signif.R index 1910e0a..680a9cf 100644 --- a/R/geom_signif.R +++ b/R/geom_signif.R @@ -107,7 +107,7 @@ stat_signif <- function(mapping = NULL, orientation = NA, ...) { if (manual) { - if (!is.null(data) & !is.null(mapping)) { + if (!is.null(data) && !is.null(mapping)) { if (!"x" %in% names(data)) mapping$x <- 1 if (!"y" %in% names(data)) mapping$y <- 1 } else { @@ -276,7 +276,7 @@ geom_signif <- function(mapping = NULL, params <- list(na.rm = na.rm, ...) if (identical(stat, "signif")) { - if (!is.null(data) & !is.null(mapping) & !manual) { + if (!is.null(data) && !is.null(mapping) && !manual) { warning("You have set data and mapping, are you sure that manual = FALSE is correct?") } @@ -285,7 +285,7 @@ geom_signif <- function(mapping = NULL, stop("Manual mode only works if with 'annotations' is provided in mapping") } - if (!is.null(data) & !is.null(mapping)) { + if (!is.null(data) && !is.null(mapping)) { if (!"x" %in% names(mapping)) { if ("xmin" %in% names(mapping)) { mapping$x <- mapping$xmin @@ -460,7 +460,7 @@ StatSignif <- ggplot2::ggproto( result <- lapply(comparisons, function(comp) { i <<- i + 1 # All entries in group should be the same - if (scales$x$map(comp[1]) == data$group[1] | manual) { + if (scales$x$map(comp[1]) == data$group[1] || manual) { test_result <- if (is.null(annotations)) { group_1 <- complete_data$y[complete_data$x == scales$x$map(comp[1]) & complete_data$PANEL == data$PANEL[1]]