Learn R Programming

activatr (version 0.2.1)

pace_formatter: Format pace durations

Description

pace_formatter takes a pace duration and returns a formatted string.

Usage

pace_formatter(pace)

Value

A formatted string representing the pace.

Arguments

pace

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

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

Run this code
pace_formatter(lubridate::dseconds(380))
pace_formatter(lubridate::dseconds(510))
pace_formatter(lubridate::dseconds(680))

Run the code above in your browser using DataLab