title: Create a variable to invoke a data.frame in R
body: <p>So I have created a program that runs a summary and anova as well as plots some graphs for me. The problem is that for each new data frame I use I need to change the variables inside the formulas. What I want to do is create a variable at the beginning of the script that I assign to the column I'm interested in and then the program does the work: </p>
  
  <pre><code>mydata &lt;- Leaves.data.csv
  attach(mydata)
  str(mydata)
  
  var &lt;- Leaves
  
  avgVaL &lt;- group_by(mydata, Treatment, Medium, Treatment:Medium) %&gt;% 
  summarise(count=sum(!is.na(var)), mean = mean(var, na.rm = T), sd = sd(var, na.rm=T), se = sd/sqrt(count)) 
  </code></pre>
  
  <p>The only thing I wish to change is <code>Leaves</code>. The problem with this code is <code>summarise</code> takes <code>var</code> as 1 single variable and returns the count, mean, sd and se of the all the data points instead of each group. </p>