title: Return value from subset of rows
body: <p>Consider the following data</p>
  
  <pre><code>df &lt;- data.frame(a=c("a","a","b"), b=c(3,4,5), c=c(4,5,6))
  df$a &lt;- as.factor(df$a)
  </code></pre>
  
  <p>The command below returns the values of "b" when a="a".</p>
  
  <pre><code>df[df$a=="a","b"]
  [1] 3 4
  </code></pre>
  
  <p>How can I return the nth value of this column? I tried the following to return the first value but which just returns the same.</p>
  
  <pre><code>df[df$a=="a","b",1]
  [1] 3 4
  </code></pre>
  
  <p>The idea is to eventually transpose this concept to multiple dataframes in a function.</p>