title: Histogram for frequency of factor variables (EDIT: Now with sample data!)
body: <p>This problem is similar to, but not the same as, another question with a similar title.</p>
  
  <p>I have a dataframe that includes a factor variable. I want to plot a histogram (preferably in <code>ggplot2</code>) that shows integers on the x axis, and a count of factors that have x observations on the y axis. So I could see that x1 factors have 1 observation, x2 factors have 2 observations , etc.</p>
  
  <p>I haven't been able to puzzle through this myself. Any help would be appreciated.</p>
  
  <p>EDIT: MY QUESTION IS DIFFERENT THAN <a href="https://stackoverflow.com/questions/21639392/make-frequency-histogram-for-factor-variables">Make Frequency Histogram for Factor Variables</a>.</p>
  
  <p>That question asks, "how many of each factor level are in my dataframe?" That is, how many dogs, how many cats, how many birds.</p>
  
  <p>I am asking, "how many factor levels have x rows?" That is, how many animals have 2 rows? If there are 3 birds and 3 dogs in my dataframe, I want a histogram that shows there are 2 factor levels that have 3 observations.</p>
  
  <p>EDIT2: Hm. I guess I'm not explaining myself well. I've downloaded training data from a Kaggle contest. The data is a set of apartment-for-rent listings. One of the fields in the data is building_id. I've factorized the building_id field. I want to plot: how many buildings have 1 listing in the set? How many buildings have 2 listings in the set? Etc.</p>
  
  <p>Example:</p>
  
  <pre><code>listingid  buildingid bedrooms bathrooms etc...
  001        001        1        1
  002        001        2        1
  003        001        1        1
  004        001        2        1
  005        002        1        1
  006        002        2        1
  007        002        1        1
  008        003        2        2
  009        003        1        1
  010        004        2        2
  011        004        3        1
  012        005        1        1
  013        006        2        2
  014        007        2        1
  015        008        1        1
  016        009        1        1    
  </code></pre>
  
  <p>The plot I want would show:</p>
  
  <pre><code>            5| X
   num        4| X
   bldgs.     3| X
              2| X   X
              1| X   X   X   X
               +--------------------------------
  num listings:  1   2   3   4
  </code></pre>
  
  <p>The plot shows that one building (building 001) has 4 listings, one building (building 002) has 3 listings, two buildings (003 and 004) have 2 listings, and 5 buildings (005, 006, 007, 008, 009) have one listing.</p>