title: Why `$` failed to subset list elements when passed to sapply/lapply as FUN argument while `[[` works?
body: <p>This post is based on this question:(<a href="https://stackoverflow.com/questions/50510682/iterate-over-list-to-get-value-by-its-name">Iterate over list to get value by its name</a>)</p>
  
  <p>I'll reproduce it here:</p>
  
  <pre><code>test_list &lt;- list(list("name"="A","property"=1),
                list("name"="B","property"=2),
                list("name"="C","property"=3))
  </code></pre>
  
  <p>The original OP found:</p>
  
  <pre><code>sapply(test_list, `$`, "property")
  </code></pre>
  
  <p>only return <code>NULL</code> values. It gives correct results if when use <code>[[</code> instead as commented by jogo:</p>
  
  <pre><code>&gt; sapply(test_list, `$`, "property")
  [[1]]
  NULL
  
  [[2]]
  NULL
  
  [[3]]
  NULL
  
  &gt; sapply(test_list, `[[`, "property")
  [1] 1 2 3
  </code></pre>
  
  <p>This also does not work:</p>
  
  <pre><code>&gt; sapply(test_list, function(x, y) `$`(x, y), y = "property")
  [[1]]
  NULL
  
  [[2]]
  NULL
  
  [[3]]
  NULL
  </code></pre>
  
  <p>However, both <code>$</code> and <code>[[</code> works on a single element of <code>test_list</code>:</p>
  
  <pre><code>&gt; `$`(test_list[[1]], 'property')
  [1] 1
  &gt; `[[`(test_list[[1]], 'property')
  [1] 1
  </code></pre>
  
  <p>I wonder why <code>$</code> and <code>[[</code> behave differently when used as <code>FUN=</code> argument for lapply/sapply. </p>