timeDiff: A function to compute time differences between t0 and ts, and...

Description Usage Arguments Details Value

Description

In process data analysis we frequently need to calculate the duration between two events. since in most cases each event is a row, we can set a particular event as t0, with NA filled for all other rows except for the event of interest. Then we calcualte the lag time for the vector ts.

Usage

1
timeDiff(t0, ts)

Arguments

t0

A vector of time marks (integer, real, or Date), with some elements (at least the first) with non-NA values

ts

A vector of timestamps of the same length and type of t0.

Details

Note that the return value is of type "difftime"; ggplot and dplyr seem to have trouble with them. You can savely convert them to seconds using "as.numeric()".

Value

A vector of real values that is ts-t0. When t0 is NA, it is back filled with the last nonNA value.


garyfeng/pdata documentation built on May 16, 2019, 5:42 p.m.