title: ggplot: remove NA factor level in legend
body: <p>How can I omit the <code>NA</code> level of a factor from a legend? </p>
  
  <p><a href="https://i.stack.imgur.com/xoIwb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xoIwb.png" alt="Pesky NA legend value....."></a></p>
  
  <p>From the <code>nycflights13</code> database, I created a new continuous variable called <code>tot_delay</code>, and then created a factor called <code>delay_class</code> with 4 levels. When I plot, I filter out <code>NA</code> values, but they still appear in the legend. Here's my code:</p>
  
  <pre><code>library(nycflights13); library(ggplot2)
  
  flights$tot_delay = flights$dep_delay + flights$arr_delay
  flights$delay_class &lt;- cut(flights$tot_delay,                                   
                             c(min(flights$tot_delay, na.rm = TRUE), 0, 20 , 120,
                               max(flights$tot_delay, na.rm = TRUE)),   
                             labels = c("none", "short","medium","long"))     
  
  filter(flights, !is.na(tot_delay)) %&gt;% 
    ggplot() +
    geom_bar(mapping = aes(x = carrier, fill = delay_class), position = "fill")
  </code></pre>