## 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)
Run the code above in your browser using DataLab