title: Error Code: Error in mutate_impl(.data, dots) : Evaluation error: k <= n is not TRUE
body: <p>I am having an issue trying to figure out an error in my data and I was hoping someone would have some insight.  The error code is:</p>
  
  <pre><code>Error in mutate_impl(.data, dots) : Evaluation error: k &lt;= n is not TRUE
  </code></pre>
  
  <p>I can get it to work on small data sets, and even subsets of my data.  The error is occurring once every 370-380 rows.  The pattern I see is that it is a "Week 1" in the data and it is only once a year.  </p>
  
  <p>Here is a link to the data in .csv form:</p>
  
  <p><a href="http://www.filedropper.com/stackoverflowdata" rel="nofollow noreferrer">http://www.filedropper.com/stackoverflowdata</a></p>
  
  <p>And here is the code I am using:</p>
  
  <pre><code>    i = 3
  QBrollavgDT &lt;- data.table(rankDT)
  QBrollavgDT &lt;- QBrollavgDT[, c("Player_Name", "Season", "Week", "FDP")]
  #QBrollavgDT &lt;- subset(QBrollavgDT, Player_Name == "K.Collins")                 &lt;- This works
  #QBrollavgDT &lt;- QBrollavgDT[c(381,759,1140,1510,1888,2264.2641), ]              &lt;- these are the rows that thorw the error
  
          #begin calculating the rolling average and eliminating players with &lt; i games played
  
          QBrollavgDT &lt;- setDT(QBrollavgDT)[, if (.N &gt;= i) .SD, by = Player_Name] #this eliminates all players with &lt; i games played
          QBrollavgDT &lt;- QBrollavgDT %&gt;% #this is the code that puts the rolling average on and names the column RollAvg
                  arrange(Player_Name, Season, Week) %&gt;% 
                  group_by(Player_Name, Season) %&gt;% 
                  mutate(RollAvg = zoo::rollapply(FDP, i, mean, by = 1, align = "right", fill = NA))
  </code></pre>
  
  <p>It must be related to the week and season, but I don't understand how. I tried every solution I could find, but couldn't get anything to work.</p>