radiusOfGyrationDT {topdowntimeratio} | R Documentation |
Radius of Gyration
Description
Calculates the time-weighted radius of Gyration provided a data.table containing latitude, longitude and a timestamp. This is the root-mean-square time-weighted average of all locations. Weighting by time is provided to adjust for unequal frequency of data collection.
Usage
radiusOfGyrationDT(lat_col, lon_col, timestamp, dist_measure = "geodesic")
Arguments
lat_col |
Time-ordered vector of latitudes |
lon_col |
Time-ordered vector of longitudes |
timestamp |
Timestamps associated with the latitude/longitude pairs |
dist_measure |
Passed through to geodist::geodist_vec, One of "haversine" "vincenty", "geodesic", or "cheap" specifying desired method of geodesic distance calculation. |
Details
Time-weighted RoG is defined as
Where
And the weighting element represents half the time interval during which a location was recorded
Value
Time-weighted radius of gyration
Examples
# Inside a data.table
dt <- data.table::data.table(
lat = c(1, 1, 1, 1, 1),
lon = c(1, 1.5, 4, 1.5, 2),
timestamp = c(100, 200, 300, 600, 900)
)
dt[, radiusOfGyrationDT(lat, lon, timestamp)]
# As vectors
radiusOfGyrationDT(
c(1, 1, 1, 1, 1),
c(1, 1.5, 4, 1.5, 2),
c(100, 200, 300, 600, 900)
)
[Package topdowntimeratio version 0.1.0 Index]