grouptime: Group by Time Threshold

Description Usage Arguments Value See Also

View source: R/grouptime.R

Description

This function groups rows by time difference. A time threshold must be given. If the time difference is longer than time threshold, rows are put in the same group. Otherwise, group number is NA.

Usage

1
2
grouptime(df, time = NULL, units = c("auto", "secs", "mins", "hours",
  "days", "weeks"), threshold = NULL, groupvar = NULL)

Arguments

df

a data frame object.

time

a POSIXct time object used to calculate time difference

units

a character string indicating which units time difference is caluclated in.

threshold

a numeric object. Value should have the same unit specified in the units parameter.

groupvar

a character string. The name of a variable that is used to group rows. Time difference is calculated using the earliest and lastest time in each group. Note: data frame is not sorted in the function, recommend to sort before running the function.

Value

a list of 1 and 0 indicating whether a set of rows are in the same group or not in any groups.

See Also

seqgroup


nyu-mhealth/Mobility documentation built on Feb. 24, 2020, 10:37 p.m.