title: R: Using an anonymous function to return the last element of a vector
body: <p>The task is: </p>
  
  <blockquote>
    <p>Now try using evaluate() along with an anonymous function to return
    the last element of the vector c(8, 4, 0). Your anonymous function
    should only take one argument which should be a variable x.</p>
  </blockquote>
  
  <p>My answer is: </p>
  
  <pre><code>evaluate(function(x){x[3]},c(8,4,0))
  </code></pre>
  
  <p>with 'evaluate' = function (func, dat) </p>
  
  <p>But the program (swirl, datacamp) is telling me this is incorrect. They're suggesting I use the <code>length()</code> function. </p>
  
  <p>How would the <code>length()</code> function return the last element in the vector <code>c(8,4,0)</code>?</p>