Skip to contents

Chooses microseconds, milliseconds, seconds, or minutes and seconds based on the size of each duration, and rounds to three significant digits.

Usage

format_duration(secs)

Arguments

secs

A numeric vector of durations in seconds.

Value

A character vector the same length as secs.

Examples

format_duration(c(0.0000123, 0.0456, 1.234, 75, 4000))
#> [1] "12.3 µs"   "45.6 ms"   "1.23 s"    "1m 15s"    "1h 6m 40s"