zone_index {cycleRtools} | R Documentation |
Generate a vector of zone "levels" from an input vector and defined boundaries.
zone_index(x, zbounds)
x |
numeric; values to be "zoned". |
zbounds |
numeric; values for zone boundaries. |
a numeric vector of zone values of the same length as x
. The
number of zone levels will be length(zbounds) + 1
.
data(ridedata) ## Best used to append to existing data. ridedata$zone <- zone_index(ridedata$power.W, c(100, 200, 300)) ## How much distance was covered in each zone? ridedata$delta.dist <- c(0, diff(ridedata$distance.km)) with(ridedata, tapply(delta.dist, zone, sum, na.rm = TRUE)) # Km.