displacement: Calculate Displacement of Spatial Locations

Description Usage Arguments Value Examples

View source: R/displacement.R

Description

This function calculates the distance between two consecutive stay events using their geolocations.

Usage

1
displacement(df, coor = NULL, groupvar = NULL)

Arguments

df

a data frame object.

coor

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

groupvar

grouping object to stratify time objects. Recommend to be ID for each individual. If groupvar is not specified, the entire data frame will be considered as one group to calculate displacement.

Value

a list of distance values. Unit is meters.

Examples

1
2
3
4
5
data(mobility)
mobility_stay<- stayevent(mobility, coor = c("lon","lat"), time = "datetime", dist.threshold = 100,
time.threshold = 30, time.units = "mins", groupvar = "id")
mobility_stay<- aggregate(cbind(id, stayeventlon, stayeventlat)~stayeventgroup, mobility_stay, mean)
mobility_stay$dispm<- displacement(mobility_stay, coor = c("stayeventlon","stayeventlat"), groupvar = "id")

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