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 7401647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:31:43+00:00 2026-05-29T04:31:43+00:00

I want this: And I thought that passing na.action=na.pass to boxplot would let NA

  • 0

I want this:

a boxplot with NA as a category name

And I thought that passing na.action=na.pass to boxplot would let NA show up in
the grouping names. Here is some sample code:

#Build a fake dataset
set.seed(212012)
nn = 100
sample_data <- data.frame( score = c( rpois(nn, 1), rpois(nn, 2),
                                      rpois(nn, 1.5), rpois(nn, 3)),
                          category = c( rep(0, nn), rep(1, nn), 
                                        rep(2, nn), rep(NA, nn) ))   

boxplot( score ~ category, data=sample_data, na.action=na.pass )

But that produces this:

enter image description here

The ‘simple’ way to get what I want is the following code, but it’s not great for exploratory data analysis:

sample_data$category2 <- sample_data$category
sample_data$category2[ is.na(sample_data$category) ] <- 'NA'
boxplot( score ~ category2, data=sample_data )

Any hints from the R Guru’s out there? I was able to find out about na.pass from this more general discussion, and the origin of na.pass from Prof. Ripley here. But there doesn’t seem to be a distinction between missing data (NA’s) appearing in the data that will be split by the factor and missing data in the factor itself. Am I missing something simple, or is this more of a feature request?

  • 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-05-29T04:31:43+00:00Added an answer on May 29, 2026 at 4:31 am

    boxplot( score ~ factor(category,exclude=NULL), data=sample_data)

    the default factor behavior is exclude=NA. I assume internal to the boxplot call is a factor call if its not already a factor. This is just forcing the factorization to include your NA values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this application that I want to support multi languages. I thought the
I thought this would be fairly easy, but I'm totally baffled. I want one
I want this for some conditional compilation code that will run in all IE's
I want to double check with others whether this would be the correct way
Just wondering if you had any thoughts on this problem. I want to make
I want this highchart - http://jsfiddle.net/zPDca/ inside a popup. But if i decrease its
I want this text all on one line, not spaced on two sepearate lines.
I want this function (defn ret-lowest-str-len Computes the lengths of two strings. Returns default
I want this to open on mouse over then close again when the mouse
I want this url http://www.youtube.com/watch?v=dgNgODPIO0w&feature=rec-HM-fresh+div to be transformed to: http://www.youtube.com/v/dgNgODPIO0w with php.

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.