title: Stacked bar graph with only top/bottom results
body: <p>I have an Excel file and am trying to create a bar chart that groups categories and shows the average rating of the category. Because there are a lot of categories, I'd also like to only show either the top 10 or bottom 10 in the resulting horizontal bar chart.</p>
  
  <pre><code> category rating
   A        10
   A        8
   A        9
   B        1
   B        4
   B        9
   C        6
   C        7
   D        9
  </code></pre>
  
  <p>Something like this (representative bar instead of the numbers): </p>
  
  <pre><code>A 9
  D 9
  ...
  C 6.5
  B 4.66
  </code></pre>
  
  <p>I know this seems super simple to do, but I can't seem to be able to get anything working after trying various answers around here. Using ggplot2 seems to be the most promising so far. Closest I've gotten is showing the number of ratings for each category...</p>
  
  <p>Edit: didn't save the work I did earlier as it wasn't the result I wanted, but it was something like this (didn't use ggplot)</p>
  
  <pre><code>dat[,c(1,12)]
  category = dat[,1] //selecting column from sheet
  rating = dat[,12] //selecting column from sheet
  rating&lt;-as.numeric(unlist(dat[,12]))
  dat&lt;-table(dat$rating,dat$category)
  barplot(dat, main="Overall Ratings",
          xlab="Ratings", col=c("skyblue","red"), horiz=TRUE,
          legend = rownames(dat))
  </code></pre>