title: How to find the variance of a subset of the data in r?
body: <p>I’m trying to find the variance of a subset of the whole data (dat) “pollutionData.csv”.</p>
  
  <p>I want the variance of the PM2.5 levels when rain = 0.</p>
  
  <pre><code>var(PM2.5, data=subset(dat, RAIN == 0))
  </code></pre>
  
  <p>The code above isn’t working.</p>
  
  <pre><code>aggregate(dat[, 6], list(dat$RAIN==0), var, na.rm=TRUE)
  </code></pre>
  
  <p>The code above outputs the variance when the rain = 0 and when rain > 0, but I want to do a hypothesis test for the variances so this isn’t helpful.</p>
  
  <p>Any help would be appreciated!</p>