In my dataset, for each individual, I have 1) the latitude and longitude for each destination of travel and 2) the number of times they visited each destination. I am hoping to measure the radius of gyration for each individual in R, but wasn't too sure how to start. Are there any functions that are available to do this?
For example, for a given individual, my dataset looks like the following. Where the duplicated rows indicate that the individual traveled to the same location twice. Based on this data, I'd like to calculate the radius of gyration.
ID lat lon
1 100 42.8142 -70.8913
2 100 42.8142 -70.8913
3 100 42.4843 -71.2041
For those unfamiliar with radius of gyration, it can be calculated as following:
This equation characterizes the spacial spread of locations visited by individual u from the trajectories' center of mass (the weighted mean point of all of the locations visited by the individual.
L is the set of locations visited by the individual u, ni is the individual’s visitation frequency of location i, N = Σ (i∈L) ni is the sum of all the single frequencies, ri and rcm are the vectors of coordinates of location i and center of mass, respectively.
Is there some sort of function that can do this?