R For Sport - Calculating Rolling Averages in R

Hi everyone, in this weeks R For Sport post we are looking at how to calculate rolling averages using different packages that have been developed specifically for R. These packages make it super simple to create your own Rolling Averages in a matter of minutes!

If you want to skip to the video, you can find it at the bottom of this page!

So let’s get straight in to it.

\[\\[0.1in]\]

Read in Data

First of all, let’s read in the data we want to use and apply a few small steps. The first thing I will do is introduce you to MUTATE, a function in the Tidyverse that allows you to add new columns to a df. All you need to do is supply a new column name and an expression that will calculate the column for you. So below let’s add a High-speed distance column to the data I have read in.

data_select <- data %>% 
  select(c(1,2,4,8,9,10,11)) %>%  
  mutate("High-Speed-Distance" = 
           `Band 5 Distance` + `Band 6 Distance` + `Band 7 Distance`) %>% 
  mutate(Date = dmy(Date)) %>%   
  select(-c(5,6,7))

head(data_select) %>% 
  kbl() %>% 
  kable_material(full_width = F, c("striped", "hover"))
DateAthlete IDAthleteTotal DistanceHigh-Speed-Distance
2020-01-271athlete 13597.65169.1000
2020-01-281athlete 15652.50347.7000
2020-01-291athlete 16305.53385.6050
2020-01-301athlete 14090.13149.4350
2020-01-311athlete 17258.00423.9375
2020-02-011athlete 10.000.0000

As you can see in the table above, we have added the new High-Speed-Distance column along with only selecting the data we want to keep. This has minimised our DF to be much smaller and easier to work with.

Using RcppRoll

The first package we are going to use is called RcppRoll. This package has a few functions within it that allow you to create rolling averages or sums. The formula is quite simple and you can see it in the below code chunk.

data_rcpp <- data_select %>% 
  group_by(`Athlete ID`) %>% 
  arrange(`Athlete ID`, Date) %>% 
  mutate(rolling_avg_rcpp_7 = 
           roll_mean(`Total Distance`, n=7, fill=0, align="right"),
         rolling_avg_rcpp_28 = 
           roll_mean(`Total Distance`, n=28, fill=0, align="right")) %>% 
  mutate(rcpp_acwr = rolling_avg_rcpp_7 / rolling_avg_rcpp_28)

data_rcpp %>% 
  filter(`Athlete ID` == 1) %>% 
  kbl() %>% 
  kable_material(full_width = F, c("striped", "hover")) %>% 
  scroll_box(height="400px")
DateAthlete IDAthleteTotal DistanceHigh-Speed-Distancerolling_avg_rcpp_7rolling_avg_rcpp_28rcpp_acwr
2020-01-271athlete 13597.650169.10000.0000.000NaN
2020-01-281athlete 15652.500347.70000.0000.000NaN
2020-01-291athlete 16305.530385.60500.0000.000NaN
2020-01-301athlete 14090.130149.43500.0000.000NaN
2020-01-311athlete 17258.000423.93750.0000.000NaN
2020-02-011athlete 10.0000.00000.0000.000NaN
2020-02-021athlete 110669.450703.95005367.6090.000Inf
2020-02-031athlete 14550.500227.05005503.7300.000Inf
2020-02-041athlete 111104.550666.90006282.5940.000Inf
2020-02-051athlete 14701.550168.15006053.4540.000Inf
2020-02-061athlete 10.0000.00005469.1500.000Inf
2020-02-071athlete 112609.350754.30006233.6290.000Inf
2020-02-081athlete 15544.200338.20007025.6570.000Inf
2020-02-091athlete 114269.000839.80007539.8790.000Inf
2020-02-101athlete 10.0000.00006889.8070.000Inf
2020-02-111athlete 15075.850178.60006028.5640.000Inf
2020-02-121athlete 118186.5621042.62507954.9950.000Inf
2020-02-131athlete 14372.280180.78508579.6060.000Inf
2020-02-141athlete 110259.050971.85008243.8490.000Inf
2020-02-151athlete 10.0000.00007451.8200.000Inf
2020-02-161athlete 15733.250265.05006232.4270.000Inf
2020-02-171athlete 115202.850979.45008404.2630.000Inf
2020-02-181athlete 15501.450349.60008465.0630.000Inf
2020-02-191athlete 110047.200924.35007302.2970.000Inf
2020-02-201athlete 10.0000.00006677.6860.000Inf
2020-02-211athlete 16274.750244.15006108.5000.000Inf
2020-02-221athlete 18464.500522.50007317.7140.000Inf
2020-02-231athlete 15066.350281.20007222.4436590.5891.0958721
2020-02-241athlete 110243.850947.15006514.0146827.9540.9540215
2020-02-251athlete 13492.2000.00006226.9796750.8000.9224060
2020-02-261athlete 19236.850558.60006111.2146855.4900.8914336
2020-02-271athlete 15324.750322.05006871.8936899.5840.9959866
2020-02-281athlete 110811.950994.65007520.0647026.5101.0702417
2020-02-291athlete 10.0000.00006310.8507026.5100.8981485
2020-03-011athlete 15083.450293.55006313.2936827.0100.9247522
2020-03-021athlete 110745.450959.50006384.9507048.2590.9058904
2020-03-031athlete 12064.3500.00006180.9716725.3940.9190497
2020-03-041athlete 10.0000.00004861.4216557.4820.7413549
2020-03-051athlete 13514.050163.40004602.7506682.9840.6887268
2020-03-061athlete 15452.050328.70003837.0506427.3660.5969864
2020-03-071athlete 14803.200205.20004523.2216400.9020.7066538
2020-03-081athlete 13782.900160.55004337.4296026.3980.7197382
2020-03-091athlete 110594.400951.90004315.8506404.7690.6738494
2020-03-101athlete 12567.8500.00004387.7796315.1980.6947967
2020-03-111athlete 10.0000.00004387.7795665.6780.7744490
2020-03-121athlete 14727.200205.20004561.0865678.3540.8032409
2020-03-131athlete 17445.150384.75004845.8145577.8570.8687591
2020-03-141athlete 15273.450243.20004912.9935766.1950.8520338
2020-03-151athlete 14009.000255.55004945.2935704.6140.8668935
2020-03-161athlete 110168.800922.45004884.4935524.8270.8840988
2020-03-171athlete 12694.2000.00004902.5435424.5680.9037665
2020-03-181athlete 10.0000.00004902.5435065.7390.9677843
2020-03-191athlete 14530.550213.75004874.4505227.5450.9324550
2020-03-201athlete 16987.250427.50004809.0365252.9910.9154852
2020-03-211Athlete 16102.800337.25004927.5145168.6450.9533475
2020-03-221Athlete 13851.300202.35004904.9865125.2500.9570237
2020-03-231Athlete 110079.500928.15004892.2295119.3800.9556290
2020-03-241Athlete 12527.9500.00004868.4795084.9430.9574303
2020-03-251Athlete 10.0000.00004868.4794755.0551.0238532
2020-03-261Athlete 17429.380251.94005282.5974830.2211.0936554
2020-03-271Athlete 110022.595572.66005716.2184802.0291.1903754
2020-03-281Athlete 17058.642203.20505852.7675054.1241.1580181
2020-03-291Athlete 112429.4201073.88007078.2125316.4801.3313720
2020-03-301Athlete 10.0000.00005638.2844932.7141.1430389
2020-03-311Athlete 16757.350402.80006242.4845100.3211.2239394
2020-04-011Athlete 14693.950226.10006913.0485267.9621.3122813
2020-04-021Athlete 10.0000.00005851.7085142.4601.1379200
2020-04-031Athlete 16658.550368.60005371.1305185.5501.0357881
2020-04-041Athlete 15490.050271.70005147.0465210.0800.9879015
2020-04-051Athlete 14481.150223.25004011.5795235.0170.7662971
2020-04-061Athlete 110278.050974.70005479.8715223.7191.0490364
2020-04-071Athlete 12575.4500.00004882.4575223.9910.9346221
2020-04-081Athlete 10.0000.00004211.8935223.9910.8062597
2020-04-091Athlete 14773.750252.70004893.8575225.6530.9365063
2020-04-101Athlete 16763.050424.65004908.7865201.2920.9437627
2020-04-111Athlete 15911.850270.75004969.0435224.0920.9511782
2020-04-121Athlete 14549.550281.20004978.8145243.3980.9495397
2020-04-131Athlete 110771.100957.60005049.2505264.9080.9590385
2020-04-141Athlete 11576.0500.00004906.4795224.9750.9390435
2020-04-151Athlete 10.0000.00004906.4795224.9750.9390435
2020-04-161Athlete 13491.250185.25004723.2645187.8570.9104462
2020-04-171Athlete 15264.900310.65004509.2435126.3440.8796216
2020-04-181Athlete 13672.700195.70004189.3645039.5550.8312965
2020-04-191Athlete 13145.450156.75003988.7795014.3460.7954733
2020-04-201Athlete 110670.400964.25003974.3935035.4500.7892826
2020-04-211Athlete 13176.8000.00004203.0715058.6230.8308727
2020-04-221Athlete 13848.450207.10004752.8505196.0670.9147014
2020-04-231Athlete 110471.850896.80005750.0795304.7271.0839537
2020-04-241Athlete 12897.5000.00005411.8795050.2591.0716041
2020-04-251Athlete 17175.350393.30005912.2575054.4271.1697185
2020-04-261Athlete 13841.800245.10006011.7364747.7271.2662346
2020-04-271Athlete 110788.200957.60006028.5645133.0201.1744674
2020-04-281Athlete 12857.6000.00005982.9644993.7431.1980922
2020-04-291Athlete 10.0000.00005433.1864826.1021.1257918
2020-04-301Athlete 15170.850185.25004675.9005010.7750.9331690
2020-05-011Athlete 17566.750450.30005342.9365043.2111.0594314
2020-05-021Athlete 15900.450296.40005160.8075057.8681.0203523
2020-05-031Athlete 14314.900270.75005228.3935051.9301.0349297
2020-05-041Athlete 110654.2501001.30005209.2575065.3661.0284068
2020-05-051Athlete 13527.3500.00005304.9365099.3631.0403135
2020-05-061Athlete 10.0000.00005304.9365099.3631.0403135
2020-05-071Athlete 14993.200223.25005279.5575107.2001.0337479
2020-05-081Athlete 18216.550502.55005372.3865159.1111.0413395
2020-05-091Athlete 16255.750304.00005423.1435171.3931.0486813
2020-05-101Athlete 15333.300235.60005568.6295199.3841.0710170
2020-05-111Athlete 110613.400937.65005562.7935193.7521.0710548
2020-05-121Athlete 13826.6000.00005605.5435274.1291.0628377
2020-05-131Athlete 10.0000.00005605.5435274.1291.0628377
2020-05-141Athlete 16004.950285.95005750.0795363.9041.0719951
2020-05-151Athlete 19632.050596.60005952.2935519.8731.0783387
2020-05-161Athlete 17699.750361.00006158.5795663.6961.0873779
2020-05-171Athlete 14891.550326.80006095.4715726.0571.0645146
2020-05-181Athlete 110631.450977.55006098.0505724.6661.0652237
2020-05-191Athlete 12823.4000.00005954.7365712.0451.0424876
2020-05-201Athlete 10.0000.00005954.7365574.6001.0681907
2020-05-211Athlete 13694.55079.80005624.6795332.5541.0547814
2020-05-221Athlete 15278.200332.50005002.7005417.5790.9234199
2020-05-231Athlete 14657.850240.35004568.1435327.6680.8574376
2020-05-241Athlete 13552.050133.00004376.7865317.3200.8231188
2020-05-251Athlete 110444.300976.60004350.0505305.0380.8199848
2020-05-261Athlete 12713.2000.00004334.3075299.8800.8178123
2020-05-271Athlete 10.0000.00004334.3075299.8800.8178123
2020-05-281Athlete 15602.150228.95004606.8215315.2840.8667122
2020-05-291Athlete 18102.550500.65005010.3005334.4200.9392399
2020-05-301Athlete 16449.550361.95005266.2575354.0300.9836061
2020-05-311Athlete 14418.450226.10005390.0295357.7291.0060287
2020-06-011Athlete 110495.600964.25005397.3575352.0621.0084630
2020-06-021Athlete 13997.6000.00005580.8435368.8571.0394843
2020-06-031Athlete 10.0000.00005580.8435368.8571.0394843
2020-06-041Athlete 16181.650291.65005663.6295411.3021.0466296
2020-06-051Athlete 18937.600501.60005782.9215437.0541.0636131
2020-06-061Athlete 17485.050311.60005930.8505480.9571.0820829
2020-06-071Athlete 15257.300283.10006050.6865478.2431.1044939
2020-06-081Athlete 110914.550994.65006110.5365488.9981.1132333
2020-06-091Athlete 12808.2000.00005940.6215452.6271.0894972
2020-06-101Athlete 10.0000.00005940.6215452.6271.0894972
2020-06-111Athlete 14576.150167.20005711.2645401.5981.0573286
2020-06-121Athlete 16963.500367.65005429.2505306.2931.0231719
2020-06-131Athlete 15621.150232.75005162.9795232.0570.9867971
2020-06-141Athlete 14499.200203.30005054.6795218.0450.9686921
2020-06-151Athlete 110618.150890.15005012.3365217.5700.9606648
2020-06-161Athlete 10.0000.00004611.1645116.7340.9011929
2020-06-171Athlete 15355.150334.40005376.1865307.9891.0128479
2020-06-181Athlete 14417.500249.85005353.5215333.8091.0036958
2020-06-191Athlete 110569.700920.55005868.6935522.7911.0626317
2020-06-201Athlete 10.0000.00005065.6715356.4390.9457162
2020-06-211Athlete 14221.800214.70005026.0435380.3590.9341464
2020-06-221Athlete 110279.950953.80004977.7295374.4890.9261770

There are a few things to notice in the function inputs. Firstly, you need to align your rolling values, with the default being center, this means that the data is equally distributed to each side of your value. I chose right, meaning that the value for our 7 or 28 day period will only start to appear once 7/28 days have passed. Because of this, our ACWR value takes 28 days to be calculated, resulting in NaN and inf values, which are blanks and infinite values. Both of these mean that the ACWR is unable to be calculated.

But now that we have some values, let’s plot them and see what they look like.

As we can see, our 7 day value appears quite early but it takes a little longer for the 28 day value to start appearing. This isn’t necessarily a bad thing, but it would be nicer to have your values from day 1. So let’s see what we have in another package!

Using the Zoo Package

The next package we are going to use is called Zoo. In much the same way as RcppRoll, Zoo provides a couple of functions for the calculation of rolling averages and sums. So let’s give it a go below.

data_zoo <- data_rcpp %>% 
  group_by(`Athlete ID`) %>% 
  arrange(`Athlete ID`, Date) %>%
  mutate(rolling_avg_zoo_7 = 
           zoo::rollmean(`Total Distance`, k = 7, fill=0,align="right"),
         rolling_avg_zoo_28 = 
           zoo::rollmean(`Total Distance`, k = 28, fill=0,align="right")) %>% 
  mutate(zoo_acwr = rolling_avg_zoo_7 / rolling_avg_zoo_28)

data_zoo %>% 
  filter(`Athlete ID` == 1) %>% 
  select(c(1:5,9:11)) %>% 
  kbl() %>% 
  kable_material(full_width = F, c("striped", "hover")) %>% 
  scroll_box(height="400px")
DateAthlete IDAthleteTotal DistanceHigh-Speed-Distancerolling_avg_zoo_7rolling_avg_zoo_28zoo_acwr
2020-01-271athlete 13597.650169.10000.0000.000NaN
2020-01-281athlete 15652.500347.70000.0000.000NaN
2020-01-291athlete 16305.530385.60500.0000.000NaN
2020-01-301athlete 14090.130149.43500.0000.000NaN
2020-01-311athlete 17258.000423.93750.0000.000NaN
2020-02-011athlete 10.0000.00000.0000.000NaN
2020-02-021athlete 110669.450703.95005367.6090.000Inf
2020-02-031athlete 14550.500227.05005503.7300.000Inf
2020-02-041athlete 111104.550666.90006282.5940.000Inf
2020-02-051athlete 14701.550168.15006053.4540.000Inf
2020-02-061athlete 10.0000.00005469.1500.000Inf
2020-02-071athlete 112609.350754.30006233.6290.000Inf
2020-02-081athlete 15544.200338.20007025.6570.000Inf
2020-02-091athlete 114269.000839.80007539.8790.000Inf
2020-02-101athlete 10.0000.00006889.8070.000Inf
2020-02-111athlete 15075.850178.60006028.5640.000Inf
2020-02-121athlete 118186.5621042.62507954.9950.000Inf
2020-02-131athlete 14372.280180.78508579.6060.000Inf
2020-02-141athlete 110259.050971.85008243.8490.000Inf
2020-02-151athlete 10.0000.00007451.8200.000Inf
2020-02-161athlete 15733.250265.05006232.4270.000Inf
2020-02-171athlete 115202.850979.45008404.2630.000Inf
2020-02-181athlete 15501.450349.60008465.0630.000Inf
2020-02-191athlete 110047.200924.35007302.2970.000Inf
2020-02-201athlete 10.0000.00006677.6860.000Inf
2020-02-211athlete 16274.750244.15006108.5000.000Inf
2020-02-221athlete 18464.500522.50007317.7140.000Inf
2020-02-231athlete 15066.350281.20007222.4436590.5891.0958721
2020-02-241athlete 110243.850947.15006514.0146827.9540.9540215
2020-02-251athlete 13492.2000.00006226.9796750.8000.9224060
2020-02-261athlete 19236.850558.60006111.2146855.4900.8914336
2020-02-271athlete 15324.750322.05006871.8936899.5840.9959866
2020-02-281athlete 110811.950994.65007520.0647026.5101.0702417
2020-02-291athlete 10.0000.00006310.8507026.5100.8981485
2020-03-011athlete 15083.450293.55006313.2936827.0100.9247522
2020-03-021athlete 110745.450959.50006384.9507048.2590.9058904
2020-03-031athlete 12064.3500.00006180.9716725.3940.9190497
2020-03-041athlete 10.0000.00004861.4216557.4820.7413549
2020-03-051athlete 13514.050163.40004602.7506682.9840.6887268
2020-03-061athlete 15452.050328.70003837.0506427.3660.5969864
2020-03-071athlete 14803.200205.20004523.2216400.9020.7066538
2020-03-081athlete 13782.900160.55004337.4296026.3980.7197382
2020-03-091athlete 110594.400951.90004315.8506404.7690.6738494
2020-03-101athlete 12567.8500.00004387.7796315.1980.6947967
2020-03-111athlete 10.0000.00004387.7795665.6780.7744490
2020-03-121athlete 14727.200205.20004561.0865678.3540.8032409
2020-03-131athlete 17445.150384.75004845.8145577.8570.8687591
2020-03-141athlete 15273.450243.20004912.9935766.1950.8520338
2020-03-151athlete 14009.000255.55004945.2935704.6140.8668935
2020-03-161athlete 110168.800922.45004884.4935524.8270.8840988
2020-03-171athlete 12694.2000.00004902.5435424.5680.9037665
2020-03-181athlete 10.0000.00004902.5435065.7390.9677843
2020-03-191athlete 14530.550213.75004874.4505227.5450.9324550
2020-03-201athlete 16987.250427.50004809.0365252.9910.9154852
2020-03-211Athlete 16102.800337.25004927.5145168.6450.9533475
2020-03-221Athlete 13851.300202.35004904.9865125.2500.9570237
2020-03-231Athlete 110079.500928.15004892.2295119.3800.9556290
2020-03-241Athlete 12527.9500.00004868.4795084.9430.9574303
2020-03-251Athlete 10.0000.00004868.4794755.0551.0238532
2020-03-261Athlete 17429.380251.94005282.5974830.2211.0936554
2020-03-271Athlete 110022.595572.66005716.2184802.0291.1903754
2020-03-281Athlete 17058.642203.20505852.7675054.1241.1580181
2020-03-291Athlete 112429.4201073.88007078.2125316.4801.3313720
2020-03-301Athlete 10.0000.00005638.2844932.7141.1430389
2020-03-311Athlete 16757.350402.80006242.4845100.3211.2239394
2020-04-011Athlete 14693.950226.10006913.0485267.9621.3122813
2020-04-021Athlete 10.0000.00005851.7085142.4601.1379200
2020-04-031Athlete 16658.550368.60005371.1305185.5501.0357881
2020-04-041Athlete 15490.050271.70005147.0465210.0800.9879015
2020-04-051Athlete 14481.150223.25004011.5795235.0170.7662971
2020-04-061Athlete 110278.050974.70005479.8715223.7191.0490364
2020-04-071Athlete 12575.4500.00004882.4575223.9910.9346221
2020-04-081Athlete 10.0000.00004211.8935223.9910.8062597
2020-04-091Athlete 14773.750252.70004893.8575225.6530.9365063
2020-04-101Athlete 16763.050424.65004908.7865201.2920.9437627
2020-04-111Athlete 15911.850270.75004969.0435224.0920.9511782
2020-04-121Athlete 14549.550281.20004978.8145243.3980.9495397
2020-04-131Athlete 110771.100957.60005049.2505264.9080.9590385
2020-04-141Athlete 11576.0500.00004906.4795224.9750.9390435
2020-04-151Athlete 10.0000.00004906.4795224.9750.9390435
2020-04-161Athlete 13491.250185.25004723.2645187.8570.9104462
2020-04-171Athlete 15264.900310.65004509.2435126.3440.8796216
2020-04-181Athlete 13672.700195.70004189.3645039.5550.8312965
2020-04-191Athlete 13145.450156.75003988.7795014.3460.7954733
2020-04-201Athlete 110670.400964.25003974.3935035.4500.7892826
2020-04-211Athlete 13176.8000.00004203.0715058.6230.8308727
2020-04-221Athlete 13848.450207.10004752.8505196.0670.9147014
2020-04-231Athlete 110471.850896.80005750.0795304.7271.0839537
2020-04-241Athlete 12897.5000.00005411.8795050.2591.0716041
2020-04-251Athlete 17175.350393.30005912.2575054.4271.1697185
2020-04-261Athlete 13841.800245.10006011.7364747.7271.2662346
2020-04-271Athlete 110788.200957.60006028.5645133.0201.1744674
2020-04-281Athlete 12857.6000.00005982.9644993.7431.1980922
2020-04-291Athlete 10.0000.00005433.1864826.1021.1257918
2020-04-301Athlete 15170.850185.25004675.9005010.7750.9331690
2020-05-011Athlete 17566.750450.30005342.9365043.2111.0594314
2020-05-021Athlete 15900.450296.40005160.8075057.8681.0203523
2020-05-031Athlete 14314.900270.75005228.3935051.9301.0349297
2020-05-041Athlete 110654.2501001.30005209.2575065.3661.0284068
2020-05-051Athlete 13527.3500.00005304.9365099.3631.0403135
2020-05-061Athlete 10.0000.00005304.9365099.3631.0403135
2020-05-071Athlete 14993.200223.25005279.5575107.2001.0337479
2020-05-081Athlete 18216.550502.55005372.3865159.1111.0413395
2020-05-091Athlete 16255.750304.00005423.1435171.3931.0486813
2020-05-101Athlete 15333.300235.60005568.6295199.3841.0710170
2020-05-111Athlete 110613.400937.65005562.7935193.7521.0710548
2020-05-121Athlete 13826.6000.00005605.5435274.1291.0628377
2020-05-131Athlete 10.0000.00005605.5435274.1291.0628377
2020-05-141Athlete 16004.950285.95005750.0795363.9041.0719951
2020-05-151Athlete 19632.050596.60005952.2935519.8731.0783387
2020-05-161Athlete 17699.750361.00006158.5795663.6961.0873779
2020-05-171Athlete 14891.550326.80006095.4715726.0571.0645146
2020-05-181Athlete 110631.450977.55006098.0505724.6661.0652237
2020-05-191Athlete 12823.4000.00005954.7365712.0451.0424876
2020-05-201Athlete 10.0000.00005954.7365574.6001.0681907
2020-05-211Athlete 13694.55079.80005624.6795332.5541.0547814
2020-05-221Athlete 15278.200332.50005002.7005417.5790.9234199
2020-05-231Athlete 14657.850240.35004568.1435327.6680.8574376
2020-05-241Athlete 13552.050133.00004376.7865317.3200.8231188
2020-05-251Athlete 110444.300976.60004350.0505305.0380.8199848
2020-05-261Athlete 12713.2000.00004334.3075299.8800.8178123
2020-05-271Athlete 10.0000.00004334.3075299.8800.8178123
2020-05-281Athlete 15602.150228.95004606.8215315.2840.8667122
2020-05-291Athlete 18102.550500.65005010.3005334.4200.9392399
2020-05-301Athlete 16449.550361.95005266.2575354.0300.9836061
2020-05-311Athlete 14418.450226.10005390.0295357.7291.0060287
2020-06-011Athlete 110495.600964.25005397.3575352.0621.0084630
2020-06-021Athlete 13997.6000.00005580.8435368.8571.0394843
2020-06-031Athlete 10.0000.00005580.8435368.8571.0394843
2020-06-041Athlete 16181.650291.65005663.6295411.3021.0466296
2020-06-051Athlete 18937.600501.60005782.9215437.0541.0636131
2020-06-061Athlete 17485.050311.60005930.8505480.9571.0820829
2020-06-071Athlete 15257.300283.10006050.6865478.2431.1044939
2020-06-081Athlete 110914.550994.65006110.5365488.9981.1132333
2020-06-091Athlete 12808.2000.00005940.6215452.6271.0894972
2020-06-101Athlete 10.0000.00005940.6215452.6271.0894972
2020-06-111Athlete 14576.150167.20005711.2645401.5981.0573286
2020-06-121Athlete 16963.500367.65005429.2505306.2931.0231719
2020-06-131Athlete 15621.150232.75005162.9795232.0570.9867971
2020-06-141Athlete 14499.200203.30005054.6795218.0450.9686921
2020-06-151Athlete 110618.150890.15005012.3365217.5700.9606648
2020-06-161Athlete 10.0000.00004611.1645116.7340.9011929
2020-06-171Athlete 15355.150334.40005376.1865307.9891.0128479
2020-06-181Athlete 14417.500249.85005353.5215333.8091.0036958
2020-06-191Athlete 110569.700920.55005868.6935522.7911.0626317
2020-06-201Athlete 10.0000.00005065.6715356.4390.9457162
2020-06-211Athlete 14221.800214.70005026.0435380.3590.9341464
2020-06-221Athlete 110279.950953.80004977.7295374.4890.9261770

The functions provided by Zoo are very similar to RcppRoll, requiring the alignment and also the delay in seeing values. So we can assume that our plot will look the same, but just to be sure, let’s plot the values below.

As we assumed, the figure looks identical to what we had previously. So let’s try our last package and see what we get.

Using the Pracma Package

The last package on the list as pracma. This package provide the basic rolling average functionality we have seen previously, with the ability to also calculate the exponentially weighted values as well. First, let’s try the simple average calc.

data_pracma <- data_zoo %>%
  group_by(`Athlete ID`) %>% 
  arrange(`Athlete ID`, Date) %>%  
  mutate(rolling_avg_pracma_7 = 
           movavg(`Total Distance` , n = 7, type="s" ),
         rolling_avg_pracma_28 = 
           movavg(`Total Distance` , n =28, type="s" )) %>% 
  mutate(pracma_acwr = rolling_avg_pracma_7 / rolling_avg_pracma_28)


data_pracma %>% 
  filter(`Athlete ID` == 1) %>% 
  select(c(1:5,12:14)) %>% 
  kbl() %>% 
  kable_material(full_width = F, c("striped", "hover")) %>% 
  scroll_box(height="400px")
DateAthlete IDAthleteTotal DistanceHigh-Speed-Distancerolling_avg_pracma_7rolling_avg_pracma_28pracma_acwr
2020-01-271athlete 13597.650169.10003597.6503597.6501.0000000
2020-01-281athlete 15652.500347.70004625.0754625.0751.0000000
2020-01-291athlete 16305.530385.60505185.2275185.2271.0000000
2020-01-301athlete 14090.130149.43504911.4534911.4531.0000000
2020-01-311athlete 17258.000423.93755380.7625380.7621.0000000
2020-02-011athlete 10.0000.00004483.9684483.9681.0000000
2020-02-021athlete 110669.450703.95005367.6095367.6091.0000000
2020-02-031athlete 14550.500227.05005503.7305265.4701.0452495
2020-02-041athlete 111104.550666.90006282.5945914.2571.0622796
2020-02-051athlete 14701.550168.15006053.4545792.9861.0449627
2020-02-061athlete 10.0000.00005469.1505266.3511.0385085
2020-02-071athlete 112609.350754.30006233.6295878.2671.0604534
2020-02-081athlete 15544.200338.20007025.6575852.5701.2004397
2020-02-091athlete 114269.000839.80007539.8796453.7441.1682953
2020-02-101athlete 10.0000.00006889.8076023.4941.1438224
2020-02-111athlete 15075.850178.60006028.5645964.2661.0107805
2020-02-121athlete 118186.5621042.62507954.9956683.2251.1902928
2020-02-131athlete 14372.280180.78508579.6066554.8391.3088965
2020-02-141athlete 110259.050971.85008243.8496749.7971.2213476
2020-02-151athlete 10.0000.00007451.8206412.3081.1621121
2020-02-161athlete 15733.250265.05006232.4276379.9720.9768739
2020-02-171athlete 115202.850979.45008404.2636781.0111.2393819
2020-02-181athlete 15501.450349.60008465.0636725.3781.2586746
2020-02-191athlete 110047.200924.35007302.2976863.7881.0638874
2020-02-201athlete 10.0000.00006677.6866589.2361.0134233
2020-02-211athlete 16274.750244.15006108.5006577.1400.9287471
2020-02-221athlete 18464.500522.50007317.7146647.0431.1008977
2020-02-231athlete 15066.350281.20007222.4436590.5891.0958721
2020-02-241athlete 110243.850947.15006514.0146827.9540.9540215
2020-02-251athlete 13492.2000.00006226.9796750.8000.9224060
2020-02-261athlete 19236.850558.60006111.2146855.4900.8914336
2020-02-271athlete 15324.750322.05006871.8936899.5840.9959866
2020-02-281athlete 110811.950994.65007520.0647026.5101.0702417
2020-02-291athlete 10.0000.00006310.8507026.5100.8981485
2020-03-011athlete 15083.450293.55006313.2936827.0100.9247522
2020-03-021athlete 110745.450959.50006384.9507048.2590.9058904
2020-03-031athlete 12064.3500.00006180.9716725.3940.9190497
2020-03-041athlete 10.0000.00004861.4216557.4820.7413549
2020-03-051athlete 13514.050163.40004602.7506682.9840.6887268
2020-03-061athlete 15452.050328.70003837.0506427.3660.5969864
2020-03-071athlete 14803.200205.20004523.2216400.9020.7066538
2020-03-081athlete 13782.900160.55004337.4296026.3980.7197382
2020-03-091athlete 110594.400951.90004315.8506404.7690.6738494
2020-03-101athlete 12567.8500.00004387.7796315.1980.6947967
2020-03-111athlete 10.0000.00004387.7795665.6780.7744490
2020-03-121athlete 14727.200205.20004561.0865678.3540.8032409
2020-03-131athlete 17445.150384.75004845.8145577.8570.8687591
2020-03-141athlete 15273.450243.20004912.9935766.1950.8520338
2020-03-151athlete 14009.000255.55004945.2935704.6140.8668935
2020-03-161athlete 110168.800922.45004884.4935524.8270.8840988
2020-03-171athlete 12694.2000.00004902.5435424.5680.9037665
2020-03-181athlete 10.0000.00004902.5435065.7390.9677843
2020-03-191athlete 14530.550213.75004874.4505227.5450.9324550
2020-03-201athlete 16987.250427.50004809.0365252.9910.9154852
2020-03-211Athlete 16102.800337.25004927.5145168.6450.9533475
2020-03-221Athlete 13851.300202.35004904.9865125.2500.9570237
2020-03-231Athlete 110079.500928.15004892.2295119.3800.9556290
2020-03-241Athlete 12527.9500.00004868.4795084.9430.9574303
2020-03-251Athlete 10.0000.00004868.4794755.0551.0238532
2020-03-261Athlete 17429.380251.94005282.5974830.2211.0936554
2020-03-271Athlete 110022.595572.66005716.2184802.0291.1903754
2020-03-281Athlete 17058.642203.20505852.7675054.1241.1580181
2020-03-291Athlete 112429.4201073.88007078.2125316.4801.3313720
2020-03-301Athlete 10.0000.00005638.2844932.7141.1430389
2020-03-311Athlete 16757.350402.80006242.4845100.3211.2239394
2020-04-011Athlete 14693.950226.10006913.0485267.9621.3122813
2020-04-021Athlete 10.0000.00005851.7085142.4601.1379200
2020-04-031Athlete 16658.550368.60005371.1305185.5501.0357881
2020-04-041Athlete 15490.050271.70005147.0465210.0800.9879015
2020-04-051Athlete 14481.150223.25004011.5795235.0170.7662971
2020-04-061Athlete 110278.050974.70005479.8715223.7191.0490364
2020-04-071Athlete 12575.4500.00004882.4575223.9910.9346221
2020-04-081Athlete 10.0000.00004211.8935223.9910.8062597
2020-04-091Athlete 14773.750252.70004893.8575225.6530.9365063
2020-04-101Athlete 16763.050424.65004908.7865201.2920.9437627
2020-04-111Athlete 15911.850270.75004969.0435224.0920.9511782
2020-04-121Athlete 14549.550281.20004978.8145243.3980.9495397
2020-04-131Athlete 110771.100957.60005049.2505264.9080.9590385
2020-04-141Athlete 11576.0500.00004906.4795224.9750.9390435
2020-04-151Athlete 10.0000.00004906.4795224.9750.9390435
2020-04-161Athlete 13491.250185.25004723.2645187.8570.9104462
2020-04-171Athlete 15264.900310.65004509.2435126.3440.8796216
2020-04-181Athlete 13672.700195.70004189.3645039.5550.8312965
2020-04-191Athlete 13145.450156.75003988.7795014.3460.7954733
2020-04-201Athlete 110670.400964.25003974.3935035.4500.7892826
2020-04-211Athlete 13176.8000.00004203.0715058.6230.8308727
2020-04-221Athlete 13848.450207.10004752.8505196.0670.9147014
2020-04-231Athlete 110471.850896.80005750.0795304.7271.0839537
2020-04-241Athlete 12897.5000.00005411.8795050.2591.0716041
2020-04-251Athlete 17175.350393.30005912.2575054.4271.1697185
2020-04-261Athlete 13841.800245.10006011.7364747.7271.2662346
2020-04-271Athlete 110788.200957.60006028.5645133.0201.1744674
2020-04-281Athlete 12857.6000.00005982.9644993.7431.1980922
2020-04-291Athlete 10.0000.00005433.1864826.1021.1257918
2020-04-301Athlete 15170.850185.25004675.9005010.7750.9331690
2020-05-011Athlete 17566.750450.30005342.9365043.2111.0594314
2020-05-021Athlete 15900.450296.40005160.8075057.8681.0203523
2020-05-031Athlete 14314.900270.75005228.3935051.9301.0349297
2020-05-041Athlete 110654.2501001.30005209.2575065.3661.0284068
2020-05-051Athlete 13527.3500.00005304.9365099.3631.0403135
2020-05-061Athlete 10.0000.00005304.9365099.3631.0403135
2020-05-071Athlete 14993.200223.25005279.5575107.2001.0337479
2020-05-081Athlete 18216.550502.55005372.3865159.1111.0413395
2020-05-091Athlete 16255.750304.00005423.1435171.3931.0486813
2020-05-101Athlete 15333.300235.60005568.6295199.3841.0710170
2020-05-111Athlete 110613.400937.65005562.7935193.7521.0710548
2020-05-121Athlete 13826.6000.00005605.5435274.1291.0628377
2020-05-131Athlete 10.0000.00005605.5435274.1291.0628377
2020-05-141Athlete 16004.950285.95005750.0795363.9041.0719951
2020-05-151Athlete 19632.050596.60005952.2935519.8731.0783387
2020-05-161Athlete 17699.750361.00006158.5795663.6961.0873779
2020-05-171Athlete 14891.550326.80006095.4715726.0571.0645146
2020-05-181Athlete 110631.450977.55006098.0505724.6661.0652237
2020-05-191Athlete 12823.4000.00005954.7365712.0451.0424876
2020-05-201Athlete 10.0000.00005954.7365574.6001.0681907
2020-05-211Athlete 13694.55079.80005624.6795332.5541.0547814
2020-05-221Athlete 15278.200332.50005002.7005417.5790.9234199
2020-05-231Athlete 14657.850240.35004568.1435327.6680.8574376
2020-05-241Athlete 13552.050133.00004376.7865317.3200.8231188
2020-05-251Athlete 110444.300976.60004350.0505305.0380.8199848
2020-05-261Athlete 12713.2000.00004334.3075299.8800.8178123
2020-05-271Athlete 10.0000.00004334.3075299.8800.8178123
2020-05-281Athlete 15602.150228.95004606.8215315.2840.8667122
2020-05-291Athlete 18102.550500.65005010.3005334.4200.9392399
2020-05-301Athlete 16449.550361.95005266.2575354.0300.9836061
2020-05-311Athlete 14418.450226.10005390.0295357.7291.0060287
2020-06-011Athlete 110495.600964.25005397.3575352.0621.0084630
2020-06-021Athlete 13997.6000.00005580.8435368.8571.0394843
2020-06-031Athlete 10.0000.00005580.8435368.8571.0394843
2020-06-041Athlete 16181.650291.65005663.6295411.3021.0466296
2020-06-051Athlete 18937.600501.60005782.9215437.0541.0636131
2020-06-061Athlete 17485.050311.60005930.8505480.9571.0820829
2020-06-071Athlete 15257.300283.10006050.6865478.2431.1044939
2020-06-081Athlete 110914.550994.65006110.5365488.9981.1132333
2020-06-091Athlete 12808.2000.00005940.6215452.6271.0894972
2020-06-101Athlete 10.0000.00005940.6215452.6271.0894972
2020-06-111Athlete 14576.150167.20005711.2645401.5981.0573286
2020-06-121Athlete 16963.500367.65005429.2505306.2931.0231719
2020-06-131Athlete 15621.150232.75005162.9795232.0570.9867971
2020-06-141Athlete 14499.200203.30005054.6795218.0450.9686921
2020-06-151Athlete 110618.150890.15005012.3365217.5700.9606648
2020-06-161Athlete 10.0000.00004611.1645116.7340.9011929
2020-06-171Athlete 15355.150334.40005376.1865307.9891.0128479
2020-06-181Athlete 14417.500249.85005353.5215333.8091.0036958
2020-06-191Athlete 110569.700920.55005868.6935522.7911.0626317
2020-06-201Athlete 10.0000.00005065.6715356.4390.9457162
2020-06-211Athlete 14221.800214.70005026.0435380.3590.9341464
2020-06-221Athlete 110279.950953.80004977.7295374.4890.9261770

The first difference we can see with the pracma calculation is the difference in our values. In the first 7 days, we are getting the average of the days preceeding that day, the then average of the full 7 days from day 7 onwards. This is the same for our 28 day value which makes this possibly a better way of calculating our values. Let’s see the plot!

As we can see, with our data starting straightaway, we get the gradual build up of our values until they then start to differ from day 7 onwards. Let’s try and calculate the EWMA version now!

data_pracma <- data_pracma %>%
  group_by(`Athlete ID`) %>% 
  arrange(`Athlete ID`, Date) %>% 
  mutate(rolling_avg_pracma_e_7 = 
           movavg(`Total Distance` , n = 7, type="e"),
         rolling_avg_pracma_e_28 = 
           movavg(`Total Distance` , n = 28, type="e")) %>% 
  mutate(pracma_e_acwr = rolling_avg_pracma_e_7 / rolling_avg_pracma_e_28)

data_pracma %>% 
  filter(`Athlete ID` == 1) %>% 
  select(c(1:5,15:17)) %>% 
  kbl() %>% 
  kable_material(full_width = F, c("striped", "hover")) %>% 
  scroll_box(height="400px")
DateAthlete IDAthleteTotal DistanceHigh-Speed-Distancerolling_avg_pracma_e_7rolling_avg_pracma_e_28pracma_e_acwr
2020-01-271athlete 13597.650169.10003597.6503597.6501.0000000
2020-01-281athlete 15652.500347.70004111.3633739.3641.0994818
2020-01-291athlete 16305.530385.60504659.9043916.3411.1898618
2020-01-301athlete 14090.130149.43504517.4613928.3261.1499709
2020-01-311athlete 17258.000423.93755202.5964157.9591.2512379
2020-02-011athlete 10.0000.00003901.9473871.2031.0079416
2020-02-021athlete 110669.450703.95005593.8234340.0481.2888850
2020-02-031athlete 14550.500227.05005332.9924354.5621.2246909
2020-02-041athlete 111104.550666.90006775.8814820.0781.4057617
2020-02-051athlete 14701.550168.15006257.2994811.9041.3003790
2020-02-061athlete 10.0000.00004692.9744480.0481.0475275
2020-02-071athlete 112609.350754.30006672.0685040.6901.3236418
2020-02-081athlete 15544.200338.20006390.1015075.4151.2590303
2020-02-091athlete 114269.000839.80008359.8265709.4551.4642073
2020-02-101athlete 10.0000.00006269.8695315.7001.1795003
2020-02-111athlete 15075.850178.60005971.3645299.1581.1268515
2020-02-121athlete 118186.5621042.62509025.1646187.9451.4585075
2020-02-131athlete 14372.280180.78507861.9436062.7261.2967669
2020-02-141athlete 110259.050971.85008461.2206352.1281.3320292
2020-02-151athlete 10.0000.00006345.9155914.0501.0730235
2020-02-161athlete 15733.250265.05006192.7495901.5811.0493372
2020-02-171athlete 115202.850979.45008445.2746543.0481.2907247
2020-02-181athlete 15501.450349.60007709.3186471.2141.1913249
2020-02-191athlete 110047.200924.35008293.7886717.8331.2345927
2020-02-201athlete 10.0000.00006220.3416254.5350.9945330
2020-02-211athlete 16274.750244.15006233.9446255.9290.9964857
2020-02-221athlete 18464.500522.50006791.5836408.2441.0598196
2020-02-231athlete 15066.350281.20006360.2746315.7001.0070578
2020-02-241athlete 110243.850947.15007331.1686586.6071.1130418
2020-02-251athlete 13492.2000.00006371.4266373.1990.9997218
2020-02-261athlete 19236.850558.60007087.7826570.6921.0786964
2020-02-271athlete 15324.750322.05006647.0246484.7651.0250215
2020-02-281athlete 110811.950994.65007688.2566783.1921.1334274
2020-02-291athlete 10.0000.00005766.1926315.3850.9130388
2020-03-011athlete 15083.450293.55005595.5066230.4240.8980939
2020-03-021athlete 110745.450959.50006882.9926541.8051.0521548
2020-03-031athlete 12064.3500.00005678.3326233.0150.9110088
2020-03-041athlete 10.0000.00004258.7495803.1520.7338682
2020-03-051athlete 13514.050163.40004072.5745645.2830.7214118
2020-03-061athlete 15452.050328.70004417.4435631.9570.7843532
2020-03-071athlete 14803.200205.20004513.8825574.8010.8096939
2020-03-081athlete 13782.900160.55004331.1375451.2220.7945259
2020-03-091athlete 110594.400951.90005896.9535805.9241.0156786
2020-03-101athlete 12567.8500.00005064.6775582.6080.9072241
2020-03-111athlete 10.0000.00003798.5085197.6010.7308194
2020-03-121athlete 14727.200205.20004030.6815165.1590.7803594
2020-03-131athlete 17445.150384.75004884.2985322.4000.9176871
2020-03-141athlete 15273.450243.20004981.5865319.0240.9365601
2020-03-151athlete 14009.000255.55004738.4405228.6780.9062405
2020-03-161athlete 110168.800922.45006096.0305569.3761.0945625
2020-03-171athlete 12694.2000.00005245.5725371.0880.9766313
2020-03-181athlete 10.0000.00003934.1795000.6680.7867307
2020-03-191athlete 14530.550213.75004083.2724968.2460.8218739
2020-03-201athlete 16987.250427.50004809.2665107.4880.9416110
2020-03-211Athlete 16102.800337.25005132.6505176.1300.9915999
2020-03-221Athlete 13851.300202.35004812.3125084.7620.9464183
2020-03-231Athlete 110079.500928.15006129.1095429.2271.1289101
2020-03-241Athlete 12527.9500.00005228.8195229.1390.9999389
2020-03-251Athlete 10.0000.00003921.6154868.5090.8055063
2020-03-261Athlete 17429.380251.94004798.5565045.1200.9511281
2020-03-271Athlete 110022.595572.66006104.5665388.3951.1329099
2020-03-281Athlete 17058.642203.20506343.0855503.5841.1525371
2020-03-291Athlete 112429.4201073.88007864.6695981.2281.3148920
2020-03-301Athlete 10.0000.00005898.5025568.7291.0592185
2020-03-311Athlete 16757.350402.80006113.2145650.7031.0818500
2020-04-011Athlete 14693.950226.10005758.3985584.7201.0310987
2020-04-021Athlete 10.0000.00004318.7985199.5670.8306073
2020-04-031Athlete 16658.550368.60004903.7365300.1870.9252007
2020-04-041Athlete 15490.050271.70005050.3155313.2810.9505078
2020-04-051Athlete 14481.150223.25004908.0235255.8920.9338135
2020-04-061Athlete 110278.050974.70006250.5305602.2481.1157182
2020-04-071Athlete 12575.4500.00005331.7605393.5030.9885523
2020-04-081Athlete 10.0000.00003998.8205021.5380.7963338
2020-04-091Athlete 14773.750252.70004192.5535004.4490.8377651
2020-04-101Athlete 16763.050424.65004835.1775125.7320.9433145
2020-04-111Athlete 15911.850270.75005104.3455179.9470.9854050
2020-04-121Athlete 14549.550281.20004965.6465136.4710.9667428
2020-04-131Athlete 110771.100957.60006417.0105525.0661.1614358
2020-04-141Athlete 11576.0500.00005206.7705252.7200.9912521
2020-04-151Athlete 10.0000.00003905.0774890.4640.7985086
2020-04-161Athlete 13491.250185.25003801.6214793.9660.7930011
2020-04-171Athlete 15264.900310.65004167.4404826.4440.8634597
2020-04-181Athlete 13672.700195.70004043.7554746.8760.8518772
2020-04-191Athlete 13145.450156.75003819.1794636.4330.8237322
2020-04-201Athlete 110670.400964.25005531.9845052.5681.0948856
2020-04-211Athlete 13176.8000.00004943.1884923.2051.0040590
2020-04-221Athlete 13848.450207.10004669.5044849.0840.9629661
2020-04-231Athlete 110471.850896.80006120.0905236.8611.1686562
2020-04-241Athlete 12897.5000.00005314.4435075.5261.0470724
2020-04-251Athlete 17175.350393.30005779.6705220.3411.1071440
2020-04-261Athlete 13841.800245.10005295.2025125.2691.0331559
2020-04-271Athlete 110788.200957.60006668.4525515.8161.2089691
2020-04-281Athlete 12857.6000.00005715.7395332.4911.0718703
2020-04-291Athlete 10.0000.00004286.8044964.7330.8634511
2020-04-301Athlete 15170.850185.25004507.8164978.9480.9053751
2020-05-011Athlete 17566.750450.30005272.5495157.4171.0223236
2020-05-021Athlete 15900.450296.40005429.5245208.6611.0424031
2020-05-031Athlete 14314.900270.75005150.8685147.0221.0007473
2020-05-041Athlete 110654.2501001.30006526.7145526.8311.1809143
2020-05-051Athlete 13527.3500.00005776.8735388.9361.0719877
2020-05-061Athlete 10.0000.00004332.6555017.2850.8635457
2020-05-071Athlete 14993.200223.25004497.7915015.6240.8967560
2020-05-081Athlete 18216.550502.55005427.4815236.3771.0364953
2020-05-091Athlete 16255.750304.00005634.5485306.6791.0617842
2020-05-101Athlete 15333.300235.60005559.2365308.5151.0472300
2020-05-111Athlete 110613.400937.65006822.7775674.3691.2023851
2020-05-121Athlete 13826.6000.00006073.7335546.9371.0949706
2020-05-131Athlete 10.0000.00004555.3005164.3890.8820597
2020-05-141Athlete 16004.950285.95004917.7125222.3590.9416649
2020-05-151Athlete 19632.050596.60006096.2975526.4761.1031075
2020-05-161Athlete 17699.750361.00006497.1605676.3571.1446004
2020-05-171Athlete 14891.550326.80006095.7575622.2321.0842237
2020-05-181Athlete 110631.450977.55007229.6815967.6951.2114694
2020-05-191Athlete 12823.4000.00006128.1105750.8471.0656013
2020-05-201Athlete 10.0000.00004596.0835354.2370.8584010
2020-05-211Athlete 13694.55079.80004370.7005239.7760.8341386
2020-05-221Athlete 15278.200332.50004597.5755242.4260.8769937
2020-05-231Athlete 14657.850240.35004612.6445202.1100.8866870
2020-05-241Athlete 13552.050133.00004347.4955088.3130.8544079
2020-05-251Athlete 110444.300976.60005871.6965457.6921.0758571
2020-05-261Athlete 12713.2000.00005082.0725268.4160.9646300
2020-05-271Athlete 10.0000.00003811.5544905.0770.7770630
2020-05-281Athlete 15602.150228.95004259.2034953.1510.8598977
2020-05-291Athlete 18102.550500.65005220.0405170.3511.0096103
2020-05-301Athlete 16449.550361.95005527.4175258.5721.0511252
2020-05-311Athlete 14418.450226.10005250.1765200.6321.0095264
2020-06-011Athlete 110495.600964.25006561.5325565.8021.1789013
2020-06-021Athlete 13997.6000.00005920.5495457.6511.0848164
2020-06-031Athlete 10.0000.00004440.4125081.2610.8738799
2020-06-041Athlete 16181.650291.65004875.7215157.1500.9454294
2020-06-051Athlete 18937.600501.60005891.1915417.8701.0873628
2020-06-061Athlete 17485.050311.60006289.6565560.4351.1311446
2020-06-071Athlete 15257.300283.10006031.5675539.5291.0888231
2020-06-081Athlete 110914.550994.65007252.3135910.2201.2270800
2020-06-091Athlete 12808.2000.00006141.2845696.2871.0781205
2020-06-101Athlete 10.0000.00004605.9635303.4400.8684860
2020-06-111Athlete 14576.150167.20004598.5105253.2820.8753594
2020-06-121Athlete 16963.500367.65005189.7575371.2280.9662143
2020-06-131Athlete 15621.150232.75005297.6065388.4640.9831383
2020-06-141Athlete 14499.200203.30005098.0045327.1360.9569879
2020-06-151Athlete 110618.150890.15006478.0415692.0331.1380891
2020-06-161Athlete 10.0000.00004858.5305299.4790.9167940
2020-06-171Athlete 15355.150334.40004982.6855303.3190.9395410
2020-06-181Athlete 14417.500249.85004841.3895242.2280.9235366
2020-06-191Athlete 110569.700920.55006273.4675609.6391.1183369
2020-06-201Athlete 10.0000.00004705.1005222.7680.9008825
2020-06-211Athlete 14221.800214.70004584.2755153.7360.8895053
2020-06-221Athlete 110279.950953.80006008.1945507.2681.0909573

The easiest of change, with type being changed to e, the function now knows to use a different moving average type. We can see that these values differ from day 2 already, which is really interesting. Let’s plot these as well!

From day 2, we can see the difference very quickly which is interesting. There is a lot more variation between these values. The more interesting thing will be the output of the ACWR values.

So let’s plot those.

Our EWMA ACWR version is different and far more varied compared to our normal rolling average version. My data isn’t perfect, so the look of this in reality might be much different, so give it a go with your data and see how it appears!

If you enjoyed this post, please leave a comment below with how your images appeared if you tried it on your data, I would love to see them.

\[\\[0.1in]\]

Video

You can find the full video showing the information discussed above, in a little more detail, below.

As always, hit like on the video and subscribe here for more videos to help you Power Performance Through Data.

Until next time,

Josh

comments powered by Disqus

Related