title: Find max/mean/min of the a subset in R
body: <p>A simple question but I can't seem to figure it out. I want to find the maximum value in a subset of my data frame.  </p>
  
  <p>To my knowledge, it would look something like:  </p>
  
  <pre><code>max(data.frame$vector1)[data.frame$vector2=="1",]  
  </code></pre>
  
  <p>but I get the error message of incorrect number of dimensions. </p>
  
  <p>This text is then supposed to be used as a logical test in another subscript</p>