title: Using CUT and Quartile to generate breaks in R function
body: <p>Following <a href="https://stackoverflow.com/questions/11725238/properly-building-a-function-in-r">some great advice from before</a>, I'm now writing my 2nd R function and using a similar logic.  However, I'm trying to automate a bit more and may be getting too smart for my own good.  </p>
  
  <p>I want to break the clients into quintiles based on the number of orders.  Here's my code to do so:</p>
  
  <pre><code># sample data
  clientID &lt;- round(runif(200,min=2000, max=3000),0)
  orders &lt;- round(runif(200,min=1, max=50),0)
  
  df &lt;- df &lt;- data.frame(cbind(clientID,orders))
  
  #function to break them into quintiles
  ApplyQuintiles &lt;- function(x) {
    cut(x, breaks=c(quantile(df$orders, probs = seq(0, 1, by = 0.20))), 
        labels=c("0-20","20-40","40-60","60-80","80-100"))
  }
  
  #Add the quintile to the dataframe
  df$Quintile &lt;- sapply(df$orders, ApplyQuintiles)
  </code></pre>
  
  <p><code>table(df$Quintile)</code>  </p>
  
  <pre><code>0-20   20-40   40-60    60-80   80-100 
  40     39      44       38      36
  </code></pre>
  
  <p>You'll see here that in my sample data, I created 200 observations, yet only 197 are listed via <code>table</code>.  The 3 left off are <code>NA</code></p>
  
  <p>Now, there are some clientIDs that have an 'NA' for quintile.  It seems if they were at the lowest break, in this case, 1, then they were not included in the cut function. </p>
  
  <p>Is there a way to make <code>cut</code> inclusive of all observations?  </p>