title: Difference between df["speed"] and df$speed
body: <p>Suppose a data frame <code>df</code> has a column <code>speed</code>, then what is difference in the way accessing the column like so:</p>
  
  <pre><code>df["speed"]
  </code></pre>
  
  <p>or like so:</p>
  
  <pre><code>df$speed
  </code></pre>
  
  <p>The following calculates the mean value correctly:</p>
  
  <pre><code>lapply(df["speed"], mean) 
  </code></pre>
  
  <p>But this prints all values under the column speed:</p>
  
  <pre><code>lapply(df$speed, mean)
  </code></pre>