Learn R Programming

hms

Overview

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

Usage

The following example showcases ways of using the hms class standalone or as a data frame column.

Internal representation

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.


Please note that the ‘hms’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('hms')

Monthly Downloads

999,981

Version

1.1.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Last Published

March 21st, 2023

Functions in hms (1.1.3)

vec_cast.hms

Casting
round_hms

Round or truncate to a multiple of seconds
Deprecated

Deprecated functions
vec_ptype2.hms

Coercion
parse_hms

Parsing hms values
hms-package

hms: Pretty Time of Day
hms

A simple class for storing time-of-day values