Skip to contents

pace_formatter takes a pace duration and returns a formatted string.

Usage

pace_formatter(pace)

Arguments

pace

A lubridate duration, returned by lubridate::duration or other methods in that family.

Value

A formatted string representing the pace.

Details

This is most useful when plotting pace as one of the axes in a graph; rather than having the "number of seconds" as the axis value, this method can convert that to a more readable format.

Most commonly, using something like ggplot2::scale_y_reverse(label = pace_formatter) will ensure the y-axis goes from "slowest" to "fastest", and shows paces like "8:30" rather than "510"

Examples

pace_formatter(lubridate::dseconds(380))
#> [1] "6:20"
pace_formatter(lubridate::dseconds(510))
#> [1] "8:30"
pace_formatter(lubridate::dseconds(680))
#> [1] "11:20"