Skip to content

suppress "Each group consists of only one observation" #6012

@andybeet

Description

@andybeet
  • Allow user to suppress messages like " geom_line(): Each group consists of only one observation. Do you need to adjust the group aesthetic?"

While you can (sometimes) eliminate this message if you use groups=1 or convert variables from factor to numeric, in one case you can not; when geom_line is used in a facet plot and one of the facets has only one data point. This makes rmd's a little ugly


  # remove all but one row where cyl == 6 (mtcars)
ind <- which(mtcars$cyl == 6)
exclude <- head(ind,-1)
mtcars2 <- mtcars |> 
  dplyr::slice(-exclude)


ggplot2::ggplot(mtcars2,ggplot2::aes(x=mpg,y=wt)) +
  ggplot2::geom_point() + 
  ggplot2::geom_line() +
  ggplot2::facet_wrap(~cyl)
#> `geom_line()`: Each group consists of only one observation.
#> ℹ Do you need to adjust the group aesthetic?

Created on 2024-07-24 with reprex v2.1.0

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