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.

60 lines
1.5 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 <- 21 - 1
  21. for(day in window:numDays)
  22. {
  23. print(length(workLoad[c((day-window):day)]))
  24. windowAverage <- mean(workLoad[c((day-window):day)])
  25. slidingAverage <- c(slidingAverage, windowAverage)
  26. }
  27. plot(window:numDays, slidingAverage, main="Sliding Average")
  28. plot(density(slidingAverage), main="Sliding Average Density")
  29. plot(density(workLoad), main="Total Work Load Average")
  30. dataTibble <- tibble(TimeSinceAugFirst = window:numDays, slidingWorkAverage = slidingAverage)
  31. ggplot(data = dataTibble) +
  32. theme(plot.title = element_text(hjust = 0.5)) +
  33. ggtitle("Team's Total Daily Load Moving Average") +
  34. geom_point(mapping = aes(x=TimeSinceAugFirst, y=slidingWorkAverage)) +
  35. labs(x = "Days Since August Twenty First 2017", y = "Teams Total Daily Load")+
  36. theme_bw()
  37. write.csv(dataTibble, "cleaned/slidingWorkAverage.csv")