title: How to subset observations based on factor level
body: <p>I have a data frame and need to group the observations based on one variable(vector)'s value into equal number of groups. Below is to illustrate, I used to cut function to create factor based on vector A' value. It create three levels, and each value of the vector A fall into one of the level/group. Now how do I extract/refer to the vector A value based on the cut level of X. For instance, if I want to select observations of A fall into level 1:[1.2.33], how to do that?  </p>
  
  <pre><code>&gt; A&lt;-1:5  
  &gt; X&lt;-cut(A,breaks=quantile(A,probs=c(0:3)/3),labels=1:3,include.lowest=TRUE)  
  &gt; A  
  [1] 1 2 3 4 5  
  &gt; X  
  [1] [1,2.33]    [1,2.33]    (2.33,3.67] (3.67,5]    (3.67,5]   
  Levels: [1,2.33] (2.33,3.67] (3.67,5]
  </code></pre>