title: R: get min value of a column conditional on a categorical variable
body: <p>I have a dataset that looks like the following:</p>
  
  <pre><code>    Attribute   estimate    
      Proximity   3.7 
      Proximity   1.54    
      Proximity   0.45    
      Waittime    0.7 
      Waittime    0.76    
      service     0.6 
      Knowledge   0.7 
  </code></pre>
  
  <p>I want to get the max and min value for each attribute. I know that I can get the result from using the following code:</p>
  
  <pre><code>min = fit.leb %&gt;%
   #For each Class
   group_by(Attribute) %&gt;%
   filter(estimate == min(estimate))
  </code></pre>
  
  <p>But since I have attribute that has only 1 value (i.e. knowledge), for these types of attributes, I want the value returned to me to be 0. Namely, I want a result like the following:</p>
  
  <pre><code>    Attribute   estimate    
      Proximity   0.45    
      Waittime    0.7 
      service     0   
      Knowledge   0
  </code></pre>
  
  <p>I don't know how to adjust the code I have to fit this extra conditions</p>