fmt_hms() formats strings representing time durations
(e.g.,"1,234.56 secs") in gtsummary objects
to a more readable hms format (e.g., "00:20:34").
Value
A gtsummary object with formatted
hms strings in all stat_ columns.
Examples
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
library(gtsummary)
library(hms)
table <-
tibble(
time =
seq(
from = parse_hms("00:00:00"),
to = parse_hms("23:59:59"),
by = parse_hms("00:00:01")
) |>
sample(1000)
) |>
tbl_summary(
label = list(time ~ "Time of Day"),
type = all_continuous() ~ "continuous2",
statistic = all_continuous2() ~ c("{mean} ({sd})", "{min}, {max}")
)
table
Characteristic
N = 1,000
table |> fmt_hms()
Characteristic
N = 1,000