In facet wrap, should you be able to suppress multiple 'geom_path: Each group consists of only one observation.' Message?

I like ggplot2, and I like facets.

Sometimes I have lots of data, of varying length, and I want to plot it in facets, with geom_line() and geom_point. Then I get lots of plots, some with points and lines, some with just a single point, because the line doesn't get drawn (and that's great!).

Whats less great is how I get a 'message' for every facet, saying the same thing, that I already know, and can't straightforwardly suppress.

These links also seem to agree with me that maybe that message is more annoying than it is useful?

Also in a knitr document, you can use: message=FALSE,, which you almost have to do as the view in RNotebooks is just the same info filling up the entire output, with the chart pushed out of the view.

The 'solution' is currently either to assign the plot to an object, and then explicitly print it to make suppressMessage() actually work or to suppress all messages from the knitr chunk. The cons being

  • the assignment then has to happen (when normally in plotting that isn't actually necessary, so just extra cruft code)
  • the whole chunk has all it's messages suppressed, even if those might be useful/needed

My question is really:

Why is printing the same message so many times helpful, when it's a bit of a bother to actually catch it and remove it?

If it was 1 message (in the form of 'geom_path: 17 facets of 50 consist of only one observation, do you need to adjust the group variable?'), or if the multiple messages were easier to catch (99% of the time I just bang a %>% ggplot() + ... at the end of my tidyverse pipe and I'm done as the plot auto-displays) it would be really nice.

Maybe I've missed a technical detail here, but I hope you don't mind the suggestion :slight_smile:

1 Like

You may want to consider posting this same information as an Issue on ggplot2's GitHub. That way the maintainers of the package can consider implementing the changes you've suggested. You can post an issue here.

1 Like

I ran into this issue in my package.
Rather than suppress warnings, I changed the plot layers slightly.
1.Facet wrap to create empty plot
2. Add geom_point for entire data frame
3. Subset the dataframe by creating a vector of groups with more than one data point, and filtering the original data for those groups.
Only plot lines for this subset.

This appears to have resolved the issue, but I can still see other relevant warnings if they occur

That's interesting. Could you point to the package source code to give me a bit more context?

Lines 250 - 281

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.