Generate a vector of W' balance values from time and power data. The
underlying algorithm is published in Skiba *et al.* (2012). `Wbal`

is a wrapper for the Rcpp function `Wbal_`

.

1 2 3 4 |

`t, P` |
numeric vectors of time and power, respectively. |

`CP` |
a critical power value for use in the calculation. |

`data` |
a data.frame/matrix object with time and power columns. |

`time` |
character; name of the time (seconds) column in |

`pwr` |
character; name of the power (watts) column in |

`noisy` |
logical; create smoother data by pooling power data into sub- and supra-CP sections. |

`character.only` |
are column name arguments given as character strings? A backdoor around non-standard evaluation. |

The algorithm used here, while based on Dr Phil Skiba's model, differs in
that values are positive as opposed to negative. The original published model
expressed W' balance as W' minus W' expended, the latter recovering with an
exponential time course when P < CP. An issue with this approach is that an
athlete might be seen to go into negative W' balance. Hence, to avoid
assumptions regarding available W', this algorithm returns W' expended (and
its recovery) as positive values; i.e. a ride is begun at 0 W' expended, and
it will *increase* in response to supra-CP efforts.

It is advisable on physiological grounds to enter smoothed power values to the function, hence this is the default behaviour. If nothing else, this prevents an unrealistic inflation of W' values that are inconsistent with estimates derived from power-time modelling.

The essence of the algorithm can be seen in the function test file.

Note that if there are `NA`

values in the power column, these are
ignored and the correspoding W' expended value assumes that of the last
available power value. `NA`

values are not allowed in the time column.

A numeric vector of W' balance values, in kilojoules or joules for
`Wbal`

or `Wbal_`

respectively.

Skiba, P. F., W. Chidnok, A. Vanhatalo, and A. M. Jones. Modeling the Expenditure and Reconstitution of Work Capacity above Critical Power. Med. Sci. Sports Exerc., Vol. 44, No. 8, pp. 1526-1532, 2012. PubMed link.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ```
## Not run:
data(ridedata)
## Basic usage.
ridedata$Wexp.kJ <- Wbal(ridedata, timer.s, power.W, 310)
## Data can be noisy or "smooth"; e.g.
Wbal_noisy <- Wbal(ridedata, timer.s, power.W, 310, noisy = TRUE)
Wbal_smth <- Wbal(ridedata, timer.s, power.W, 310, noisy = FALSE)
## Plot:
ylim <- rev(extendrange(Wbal_noisy)) # Reverse axes.
plot(ridedata$timer.min, Wbal_noisy, type = "l", ylim = ylim,
main = "NOISY")
plot(ridedata$timer.min, Wbal_smth, type = "l", ylim = ylim,
main = "Smooooth")
## Example of NA handling.
d <- data.frame(t = seq_len(20), pwr = rnorm(20, 300, 50), Wexp.J = NA)
d[14:16, "pwr"] <- NA
d[, "Wexp.J"] <- Wbal(d, "t", "pwr", CP = 290)
print(d)
## Using underlying Rcpp function:
Wbal_(t = 1:20, P = rnorm(20, 300, 50), CP = 300) # Values are in joules.
## End(Not run)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.