title: R Generic References to Data Frames and Variables
body: <p>I would like to know how to make a reference to a data frame and variable generic, please. Say I have a data frame named 's' and a variable in that data frame named 'Y'.</p>
  
  <p>Regular R code:</p>
  
  <pre><code>look = s$Y
  </code></pre>
  
  <p>What I would like to do:</p>
  
  <pre><code>data = s
  
  variable = Y
  
  look = data$variable (which functions the same as look = s$Y)
  </code></pre>
  
  <p>Any thoughts? The reason I would like to do this is that I have <code>s$Y</code> throughout my code, and later I may want to change <code>s</code> for <code>t</code> (or <code>Y</code> for some other variable), and don't want to have to go through all of my code manually replacing <code>s$Y</code> with <code>t$Y</code> where I need it changed.</p>
  
  <p>Thanks!</p>