Skip to content

Instantly share code, notes, and snippets.

@clarle
Last active September 14, 2018 21:50
Show Gist options
  • Save clarle/27e58f67784645be4746ba82456771ef to your computer and use it in GitHub Desktop.
Save clarle/27e58f67784645be4746ba82456771ef to your computer and use it in GitHub Desktop.
Summing hours in HH:MM:SS format in R
library(dplyr)
library(tidyr)
library(lubridate)
# Parse data from HH:MM:SS format into something that can be used by `lubridate`
hours %>%
separate(Duration, into = c("hours", "minutes", "seconds"), sep = ":", convert = TRUE) %>%
summarize(total_time = duration(hour = sum(hours), minute = sum(minutes), second = sum(seconds)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment