Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8806305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:05:53+00:00 2026-06-14T02:05:53+00:00

When passing missing values to ggplot, it’s very kind, and warns us that they

  • 0

When passing missing values to ggplot, it’s very kind, and warns us that they are present. This is acceptable in an interactive session, but when writing reports, you do not the output get cluttered with warnings, especially if there’s many of them. Below example has one label missing, which produces a warning.

library(ggplot2)
library(reshape2)
mydf <- data.frame(
  species = sample(c("A", "B"), 100, replace = TRUE), 
  lvl = factor(sample(1:3, 100, replace = TRUE))
)
labs <- melt(with(mydf, table(species, lvl)))
names(labs) <- c("species", "lvl", "value")
labs[3, "value"] <- NA
ggplot(mydf, aes(x = species)) + 
   stat_bin() + 
   geom_text(data = labs, aes(x = species, y = value, label = value, vjust = -0.5)) +
   facet_wrap(~ lvl)

enter image description here

If we wrap suppressWarnings around the last expression, we get a summary of how many warnings there were. For the sake of argument, let’s say that this isn’t acceptable (but is indeed very honest and correct). How to (completely) suppress warnings when printing a ggplot2 object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:05:54+00:00Added an answer on June 14, 2026 at 2:05 am

    A more targeted plot-by-plot approach would be to add na.rm=TRUE to your plot calls.
    E.g.:

      ggplot(mydf, aes(x = species)) + 
          stat_bin() + 
          geom_text(data = labs, aes(x = species, y = value, 
                                     label = value, vjust = -0.5), na.rm=TRUE) +
          facet_wrap(~ lvl)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am passing values from the img src like this: PageA: <img src=watermark.php?fname=<?php echo
passing post data using cURL requires that the name of the input. However, I
I'm passing in some values to my controller action and everything is binding up
Wierd behaviour when passing values to and from second form. ParameterForm pf = new
I have a series of ggplot graphs that I'm repeating with a few small
When passing a hash table to my PowerShell function, it complains that it receives
i have a variable that receive the string like this: 'BA','RJ','SC' and i need
So, I'm passing some values via jQuery to the server, which generates PDF garble.
Hopefully I'm not missing something obvious... I'm creating a function that will ease in
I have a core data object that has a bunch of optional values. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.