Guest User

Untitled

a guest
Oct 22nd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Error in mutate_impl(.data, dots) : Evaluation error: k <= n is not TRUE
  2.  
  3. i = 3
  4. QBrollavgDT <- data.table(rankDT)
  5. QBrollavgDT <- QBrollavgDT[, c("Player_Name", "Season", "Week", "FDP")]
  6. #QBrollavgDT <- subset(QBrollavgDT, Player_Name == "K.Collins") <- This works
  7. #QBrollavgDT <- QBrollavgDT[c(381,759,1140,1510,1888,2264.2641), ] <- these are the rows that thorw the error
  8.  
  9. #begin calculating the rolling average and eliminating players with < i games played
  10.  
  11. QBrollavgDT <- setDT(QBrollavgDT)[, if (.N >= i) .SD, by = Player_Name] #this eliminates all players with < i games played
  12. QBrollavgDT <- QBrollavgDT %>% #this is the code that puts the rolling average on and names the column RollAvg
  13. arrange(Player_Name, Season, Week) %>%
  14. group_by(Player_Name, Season) %>%
  15. mutate(RollAvg = zoo::rollapply(FDP, i, mean, by = 1, align = "right", fill = NA))
Add Comment
Please, Sign In to add comment