title: Refer to the last column in R
body: <p>I am trying to do some manipulation on the last column in a generic way.</p>
  
  <p>I found here on the forums this nice piece of code that returns the name of the last columns:</p>
  
  <pre><code>tail(names(train),1) #returns [1] "last"
  </code></pre>
  
  <p>I still can't figure out how to reference directly to my dataset's last columns as:</p>
  
  <p><code>data$last</code></p>