radiusofgyration: Calculate Radius of Gyration of Spatial Points

View source: R/radiusofgyration.R

radiusofgyrationR Documentation

Calculate Radius of Gyration of Spatial Points

Description

This function calculates radius of gyration, defined as the distance moved within a certain time period. Distance is calculated using Vincenty's formula.

Usage

radiusofgyration(
  df,
  coor = NULL,
  time = NULL,
  time.units = c("hour", "date", "month"),
  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.

time.units

time units used to group spatial location points. Choose from hour, date, and month. Radius of gyration is calculated within each time frame.

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 list of radius of gyration value matching to each spatial point in data frame. points in the same time period sepecified in time.units have the same radius of gyration.

See Also

sdspatialpoints

Examples

data("mobility")
mobility$rg<- radiusofgyration(mobility, coor = c("lon","lat"), time = "datetime", time.units = "date", groupvar = "id")


nyu-mhealth/Mobility documentation built on July 4, 2025, 9:54 a.m.