79562847

Date: 2025-04-08 18:57:07
Score: 5.5
Natty:
Report link

Great question and great answer! https://stackoverflow.com/users/12109788/jpsmith

I have added more variables in c() and I can't get it to sum the medians etc for each variable. Instead I get a list per hour from the first value. How can I fix this?

library(dplyr)
library(chron)
library(gtsummary)

chrontest <- chestdf %>%
  select(tts_sec, ttl_sec, ttprov1_sec, deltatrop_sec, vistelse_sec) %>%
  drop_na() %>%
  mutate(across(ends_with("_sec"), ~ format(as.POSIXct(.), "%H:%M:%S"))) %>%
  mutate(across(ends_with("_sec"), ~ chron::times(.)))

summary_table <- chrontest %>%
  tbl_summary(
    include = c("tts_sec", "ttl_sec", "ttprov1_sec", "deltatrop_sec", "vistelse_sec"),
    label = list(
      tts_sec ~ "Tid till S",
      ttl_sec ~ "Tid till L",
      ttprov1_sec ~ "Tid till provtagn 1",
      deltatrop_sec ~ "Tid till provtagn 2",
      vistelse_sec ~ "Vistelsetid"
    ),
    type = list(
      all_continuous() ~ "continuous2"
    ),
    statistic = list(
      all_continuous() ~ c(
        "{mean}",
        "{median} ({p25}, {p75})",
        "{min}, {max}"
      )
    ),
    digits = list(
      all_continuous() ~ 2
    )
  )
Reasons:
  • Blacklisted phrase (0.5): How can I
  • Blacklisted phrase (1): stackoverflow
  • Blacklisted phrase (1): How can I fix this
  • RegEx Blacklisted phrase (1.5): How can I fix this?
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: ellinor berglund