You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The hms package provides a simple class for storing durations or time-of-day values and displaying them in the hh:mm:ss format. This class is intended to simplify data exchange with databases, spreadsheets, and other data sources:
Stores values as a numeric vector that contains the number of seconds since midnight
Supports construction from explicit hour, minute, or second values
Supports coercion to and from various data types, including POSIXt
Can be used as column in a data frame
Based on the difftime class
Values can exceed the 24-hour boundary or be negative
By default, fractional seconds up to a microsecond are displayed, regardless of the value of the "digits.secs" option
Installation
# The easiest way to get hms is to install the whole tidyverse:install.packages("tidyverse")# Alternatively, install just hms:install.packages("hms")# Or the the development version from GitHub:# install.packages("devtools")devtools::install_github("tidyverse/hms")
Usage
The following example showcases ways of using the hms class standalone or as a data frame column.
Objects of the hms and its underlying difftime classes are stored as number of seconds since 00:00:00. Use as.numeric() and as_hms() to convert to and from numbers.