hms v0.4.2

0

Monthly downloads

0th

Percentile

Pretty Time of Day

Implements an S3 class for storing and formatting time-of-day values, based on the 'difftime' class.

Readme

hms

Travis-CI Build Status AppVeyor Build Status codecov CRAN\_Status\_Badge

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

# 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.

library(hms)
hms(56, 34, 12)
#> 12:34:56
as.hms(1)
#> 00:00:01
as.hms("12:34:56")
#> 12:34:56
as.hms(Sys.time())
#> 16:45:12.828186
as.POSIXct(hms(1))
#> [1] "1970-01-01 00:00:01 UTC"

data.frame(hours = 1:3, hms = hms(hours = 1:3))
#>   hours      hms
#> 1     1 01:00:00
#> 2     2 02:00:00
#> 3     3 03:00:00

Functions in hms

Name Description
parse_hms Parsing hms values
hms A simple class for storing time-of-day values
round_hms Round or truncate to a multiple of seconds
No Results!

Last month downloads

Details

Date 2018-03-10
License GPL-3
Encoding UTF-8
LazyData true
URL https://github.com/tidyverse/hms
BugReports https://github.com/tidyverse/hms/issues
RoxygenNote 6.0.1.9000
NeedsCompilation no
Packaged 2018-03-10 15:21:11 UTC; muelleki
Repository CRAN
Date/Publication 2018-03-10 21:33:37 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/hms)](http://www.rdocumentation.org/packages/hms)