stayevent: Calculate Stay Events

Description Usage Arguments Value Note References See Also Examples

Description

This function calculates stay events based on spatial locations and time stamps of mobility data. A distance threshold and a time threshold are given to determine if points are in the same stay event set. The centroid of points in one stay event set is calculated as the spatial location of the stay event.

Usage

1
2
3
stayevent(df, coor = NULL, time = NULL, dist.threshold = NULL,
  time.threshold = NULL, time.units = c("auto", "secs", "mins", "hours",
  "days", "weeks"), groupvar = NULL, ...)

Arguments

df

a data frame object.

coor

longitude and latitude of the spatial points in the format of c("lon","lat").

time

a POSIXct time object, used to calculate time period.

dist.threshold

a distance threshold used to determine if points are in the same group. The format is numeric. Unit is meters.

time.threshold

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

time.units

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

groupvar

grouping object to stratify time objects. Recommend to be ID for each individual. If groupvar is not specified, time.units will be used to sort data and calculate radius of gyration.

Value

a data frame with three new columns added showing stayevents and locations.

Note

stayevent function doesn't sort the data frame. It is recommended to sort data frame based on time and then run the function.

References

Toole, J.L., et al. The path most traveled: Travel demand estimation using big data resources. Transport. Res. Part C (2015), http://dx.doi.org/10.1016/j.trc.2015.04.022

See Also

groupdist,grouptime,seqgroup

Examples

1
2
3
data(mobility)
mobility_stay<- stayevent(mobility, coor = c("lon","lat"), time = "datetime", dist.threshold = 100, 
                 time.threshold = 30, time.units = "mins", groupvar = "id")

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