title: Difference between iris$Sepal.Width & "Sepal.Width" in []
body: <pre><code>subset(iris, Sepal.Width  &gt; 4 &amp; Sepal.Length &gt; 5, select = c(Sepal.Width,Sepal.Length,Species))
  </code></pre>
  
  <p>I was checking out the subset function but I thought the same thing can be accomplished easier so why remember a new function.</p>
  
  <p>So i wrote the below code to replicate the above subset function</p>
  
  <p>1)   </p>
  
  <pre><code> iris["Sepal.Width" &gt; 4 &amp; "Sepal.Length" &gt; 5,c("Sepal.Width", "Sepal.Length","Species")]
  </code></pre>
  
  <p>But the &amp; condition is not working in here and when I checked the below code and it worked</p>
  
  <p>2)   </p>
  
  <pre><code> iris[iris$Sepal.Width &gt; 4 &amp; iris$Sepal.Length &gt; 5,c("Sepal.Width", "Sepal.Length","Species")]
  </code></pre>
  
  <p>Please explain</p>
  
  <ul>
  <li>How code 1) &amp; 2) are different I expected both 1) &amp; 2) to give same
  result. </li>
  <li>Since we have code 2) why should we use subset function? Any<br>
  scenario where subset function is better?</li>
  </ul>
  
  <p>Thanks</p>