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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:25:05+00:00 2026-05-22T15:25:05+00:00

Is it possible to filter out subsets of the data that have small numbers

  • 0

Is it possible to filter out subsets of the data that have small numbers of observations within a ggplot2 call?

For example, take the following plot: qplot(price,data=diamonds,geom="density",colour=cut)

Density plot

The plot is a little busy, and I would like the exclude the cut values with a small number of observations, ie,

> xtabs(~cut,diamonds)
cut
     Fair      Good Very Good   Premium     Ideal 
     1610      4906     12082     13791     21551

the Fair and Good qualities of the cut factor.

I’m wanting a solution that can fit an arbitrary data set and if possible be able to select not just by a threshold number of observations, but by top 3 for example.

  • 1 1 Answer
  • 3 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-22T15:25:05+00:00Added an answer on May 22, 2026 at 3:25 pm
    ggplot(subset(diamonds, cut %in% arrange(count(diamonds, .(cut)), desc(freq))[1:3,]$cut),
      aes(price, colour=cut)) + 
      geom_density() + facet_grid(~cut)
    
    1. count counts up each elements into data.frame.
    2. arrange orders a data.frame based on the specified column.
    3. desc enables reversed-order sorting.
    4. finally subset the rows whose cut is included in the top 3 by %in%.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have links like this www.somestuff.com/index.php?getsome=1:someInt:3 Is it possible to filter out the 1
Is it possible to filter numbers from the variable. I can show you one
Is it possible to write a servlet filter to take inspect HTTP response codes?
Is it possible to create a filter in a Drupal 6 View that is
Is it possible to combine Underscore's filter and map? I currently have two separate
Is it possible to make the groupby filter order in descending order? I have
Possible Duplicate: C++ templates that accept only certain types For example, if we want
I have a class built with Moose that's essentially a data container for an
Is it possible to filter out only the shortcode from the post and then
Is it possible to filter out different sorts of exceptions out of my debug

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.