title: lml, dplyr, and summary - did I break something?
body: <p>Following up on an analysis that I <a href="https://stackoverflow.com/questions/26765426/linear-model-and-dplyr-a-better-solution">got a lot of help on previously</a>, I tried re-running a script today and got roadblocked. Not sure if something got updated that blew up or what. I'm trying to get a slope based on data points in a hierarchical type structure. The end result is something like:</p>
  
  <pre><code>Var1    Var2    Var3    Max Min Var Avg_Temp    Count   Pearson Slope
  X2  X2  X6  156 7   149 28  51  -0.049  -0.111
  X1  X2  X6  84  1   83  24  51  -0.345  -0.532
  X1  X2  X7  184 8   176 33  45  -0.236  -0.825
  X1  X4  X7  193 10  183 32  44  -0.131  -0.487
  X1  X2  X5  33  4   29  21  34  -0.343  -0.251
  X1  X1  X5  51  10  41  23  21  -0.088  -0.091
  X1  X4  X6  62  7   54  23  20  0.045   0.070
  X3  X2  X6  61  18  43  31  18  -0.345  -0.491
  </code></pre>
  
  <p>The raw data I used to crunch this is here: <a href="http://pastebin.com/pGyeCFpH" rel="nofollow noreferrer">http://pastebin.com/pGyeCFpH</a></p>
  
  <p>The feedback I got from the previous thread was educational, but I think my example made the ask more complicated. In any case, the script I got to work was:</p>
  
  <pre><code>library(dplyr)
  
  data &lt;- read.table("clipboard",sep="\t",quote="",header=T)
  
  newdata = summarise(group_by(data
                                ,Var1
                                ,Var2
                                ,Var3
                                )
                       ,Max = max(Temp)
                       ,Min = min(Temp)
                       ,Var = max(Temp) - min(Temp) 
                       ,Avg_Temp = mean(Temp)
                       ,Count = length(Temp)
                       ,Slope = summary(lm(Temp ~ Time))$coeff[2]
                       ,Pearson = cor(Time, Temp, method="pearson")
                       )
  
  sortNewdata &lt;- newdata3[order(-newdata3$Count),]
  row.names(sortNewdata)&lt;-NULL
  </code></pre>
  
  <p>Which all works save for the slope function above. Before the script worked I was trying just a bare <code>Slope = lm()</code>, but it seemed like R couldn't resolve the column names inside my data variable. So I put <code>summary(lm())</code> and that gave me the slopes I was looking for. I think after updating R (I haven't revisited this script in a while), something broke to where it's returning a different error than before:</p>
  
  <p><code>Error in terms.formula(formula, data = data) : 
    invalid term in model formula</code></p>
  
  <p>Is there a quick fix for this? I feel like I'm missing something very simple, given the classic case of "well it was working before but now it doesn't"-itis.</p>