difftime.default: Convenience Function for Computing Time Differences

difftime.defaultR Documentation

Convenience Function for Computing Time Differences

Description

Subtracts time2 from time1. If both are of class POSIXt, gives the result in hours.

Usage

difftime.default(time1, time2)
difftime.hours(time1, time2)

Arguments

time1, time2

Two time vectors of the same length, either both numeric of both of class POSIXt.

Details

If time1 and time2 are both numeric then regular subtraction is used, but if both are of class POSIXt, then difftime is used and the result is converted into hours.

difftime.hours does the same, but only operates on POSIXt objects.

Value

A numeric vector containing the time difference.

Author(s)

Benjamin Rich <mail@benjaminrich.net>

See Also

difftime blk.tad blk.relativeTime

Examples

time1 <- strptime("2011-01-12 16:58", "%Y-%m-%d %H:%M")
time2 <- strptime("2011-01-11 09:13", "%Y-%m-%d %H:%M")
difftime.default(time1, time2)  # In hours

benjaminrich/PCSmisc documentation built on Feb. 11, 2024, 9:25 p.m.