datafest competition 2019
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.4 KiB

  1. source("readData.R")
  2. library(tidyverse)
  3. RPEData <-readNArpeData()
  4. numDays <- max(RPEData$TimeSinceAugFirst)
  5. dayList <- 0:numDays
  6. workLoad <- c()
  7. averageWorkLoad <- c()
  8. for(day in dayList)
  9. {
  10. total <- 0
  11. daylyActivities <- subset(RPEData, TimeSinceAugFirst == day)
  12. cat("day: ", day, "\n",sep="")
  13. cat("Activity count:", length(daylyActivities$DailyLoad), "\n", sep="")
  14. averageWorkLoad <- c(averageWorkLoad, mean(daylyActivities$SessionLoad, na.rm = T))
  15. workLoad <- c(workLoad, sum(daylyActivities$SessionLoad, na.rm = T))
  16. }
  17. plot(dayList, averageWorkLoad, main="Average Work Load")
  18. plot(dayList, workLoad, main="Daily Total Work Load")
  19. slidingAverage <- c()
  20. window <- 7 - 1
  21. for(day in window:numDays)
  22. {
  23. windowAverage <- mean(workLoad[c((day-window):day)])
  24. slidingAverage <- c(slidingAverage, windowAverage)
  25. }
  26. plot(window:numDays, slidingAverage, main="Sliding Average")
  27. plot(density(slidingAverage), main="Sliding Average Density")
  28. plot(density(workLoad), main="Total Work Load Average")
  29. dataTibble <- tibble(TimeSinceAugFirst = window:numDays, slidingWorkAverage = slidingAverage)
  30. ggplot(data = dataTibble) +
  31. theme(plot.title = element_text(hjust = 0.5)) +
  32. ggtitle("Team's 7 Day Moving Average") +
  33. geom_point(mapping = aes(x=TimeSinceAugFirst, y=slidingWorkAverage)) +
  34. labs(x = "Days Since August Seventh 2017", y = "Teams Total Daily Load")+
  35. theme_bw()
  36. write.csv(dataTibble, "cleaned/slidingWorkAverageSevenDay.csv")