Skip to content

geom_linerange() issues warning about missing values, irrespective of whether na.rm is set to TRUE or FALSE #4927

Description

@IndrajeetPatil

Just like other geom_*() functions, I'd expect this function not to generate a warning when na.rm = TRUE.

library(ggplot2)

df <- data.frame(
  trt = factor(c(1, 1, 2, 2)),
  resp = c(1, 5, NA, 4),
  group = factor(c(1, 1, 1, 2)),
  upper = c(1.1, 5.3, NA, 4.2),
  lower = c(0.8, 4.6, 2.4, NA)
)

p <- ggplot(df, aes(trt, resp, colour = group))

p + geom_linerange(aes(ymin = lower, ymax = upper), na.rm = FALSE)
#> Warning: Removed 2 rows containing missing values (geom_segment).

p + geom_linerange(aes(ymin = lower, ymax = upper), na.rm = TRUE)
#> Warning: Removed 2 rows containing missing values (geom_segment).

Created on 2022-08-01 by the reprex package (v2.0.1.9000)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions