difftime.days: Compute Time Difference In Days

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Computes the number of days between two vectors of class Date or POSIXt. In the latter case, the time portion is ignored.

Usage

1
difftime.days(time1, time2)

Arguments

time1, time2

Two vectors of the same length, both either of class Date or POSIXt.

Details

This function considers the calendar date portion of a POSIXt object only. Thus, a day need not correspond to a 24 hour period (see example).

Value

An integer vector containing the number of days between time1 and time2.

Author(s)

Ben Rich <[email protected]>

See Also

difftime.default difftime

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
time1 <- strptime("2011-12-22 00:03", "
time2 <- strptime("2011-12-22 00:01", "
time3 <- strptime("2011-12-21 23:59", "
time4 <- strptime("2011-12-20 00:01", "
difftime.days(time1, time2)  # 2 minutes difference, on the same day so considered 0 days 
difftime.days(time2, time3)  # Also 2 minutes difference but on different days, so considered one day
difftime.days(time3, time4)  # Although only 47 hours and 58 minutes difference, still considered one day

## End(Not run)

benjaminrich/PCSmisc documentation built on Dec. 17, 2017, 12:50 a.m.