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.

92 lines
2.2 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. daylyActivities <- subset(RPEData, TimeSinceAugFirst == day)
  11. cat("day: ", day, "\n",sep="")
  12. cat("Activity count:", length(daylyActivities$DailyLoad), "\n", sep="")
  13. averageWorkLoad <- c(averageWorkLoad, mean(daylyActivities$SessionLoad, na.rm = T))
  14. workLoad <- c(workLoad, sum(daylyActivities$SessionLoad, na.rm = T))
  15. }
  16. plot(dayList, averageWorkLoad, main="Average Work Load")
  17. plot(dayList, workLoad, main="Daily Total Work Load")
  18. slidingAverage <- c()
  19. window <- 31 - 1
  20. for(day in window:numDays)
  21. {
  22. windowAverage <- mean(workLoad[c((day-window):day)])
  23. slidingAverage <- c(slidingAverage, windowAverage)
  24. }
  25. plot(window:numDays, slidingAverage, main="Sliding Average")
  26. plot(density(slidingAverage), main="Sliding Average Density")
  27. plot(density(workLoad), main="Total Work Load Average")
  28. dataTibble <- tibble(TimeSinceAugFirst = window:numDays, slidingWorkAverage = slidingAverage)
  29. ggplot(data = dataTibble) +
  30. theme(plot.title = element_text(hjust = 0.5)) +
  31. ggtitle("Team's 7 Day Moving Average") +
  32. geom_point(mapping = aes(x=TimeSinceAugFirst, y=slidingWorkAverage)) +
  33. labs(x = "Days Since August Seventh 2017", y = "Teams Total Daily Load")+
  34. theme_bw()
  35. write.csv(dataTibble, "cleaned/slidingWorkAverageSevenDay.csv")
  36. ################################ Wellness Data ###################################
  37. fatigueData <- readFatigueSums()
  38. dayNum <- max(fatigueData$TimeSinceAugFirst)
  39. dayList <- 0:dayNum
  40. slidingAverage <- c()
  41. window <- 21 - 1
  42. for(day in window:dayNum)
  43. {
  44. windowAverage <- mean(fatigueData$fatigueSum[c((day-window):day)], na.rm = T)
  45. slidingAverage <- c(slidingAverage, windowAverage)
  46. }
  47. graphingTib <- tibble(slidingAverage = slidingAverage, days = window:dayNum)
  48. ggplot(data = graphingTib) +
  49. theme(plot.title = element_text(hjust = 0.5)) +
  50. ggtitle("Team's Average Normalized Fatigue") +
  51. geom_point(mapping = aes(x=days, y=slidingAverage)) +
  52. labs(x = "Days Since August Twenty First 2017", y = "Teams Average Normalized Fatigue")+
  53. theme_bw()
  54. plot(density(slidingAverage))
  55. plot(window:dayNum, slidingAverage)