0

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:

enter image description here

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?

ltong
  • 501
  • 1
  • 8
  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jun 30 '22 at 13:22
  • Thanks for the feedback! I just added a toy dataset – ltong Jun 30 '22 at 13:34

0 Answers0