Skip to content

Commit

Permalink
Use scalar logical operators in conditionals (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil authored May 31, 2024
1 parent ab52606 commit 4dcc95b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/geom_signif.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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?")

Check warning on line 280 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=280,col=7,[condition_call_linter] Use warning(., call. = FALSE) not to display the call in an error message.
}

Expand All @@ -285,7 +285,7 @@ geom_signif <- function(mapping = NULL,
stop("Manual mode only works if with 'annotations' is provided in mapping")

Check warning on line 285 in R/geom_signif.R

View workflow job for this annotation

GitHub Actions / lint

file=R/geom_signif.R,line=285,col=9,[condition_call_linter] Use stop(., call. = FALSE) not to display the call in an error message.
}

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
Expand Down Expand Up @@ -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]]
Expand Down

0 comments on commit 4dcc95b

Please sign in to comment.